Re: Any help is appreciated.
Quote:
Originally Posted by
Nick007
No matter what I put in for the name, it only reads the 2nd line from the file.
this is what the text file reads as:
Talon 3 30
Leo 4 45
Mandy 6 150
Phantom 9 175
Cody 13 300
so the line I get when I enter the name "Talon" for example gets me "The animal Leo was checked into the clinic 3 times and the total charges were $30.00 with the average charge being $10.00." which is great if I was trying to get Leo's info, but not if I try for anything else.
Are you sure it reads the second line? Maybe you should look closer. ;)
Did you write down the steps that the program should take before writing any code? If so, did you step through your program with the debugger to check that each step is performed correctly? That's the approach you need to take to write working programs. The first step is to explain the steps of your program in normal English.
Re: Any help is appreciated.
Before posting code, please format it properly with indents etc and use code tags. These are [ code] and [ /code] (without the space!). Go Advanced, select code then click '#'
If there are 100 lines in the file and the name of the animal occurs, say, on line 92, how would you keep reading lines from the file until the animal's name is found or end of file is reached? (Hint - you need a loop).
As D_Drmmr said, you first need to design the program and check the program design is correct by working through it and making changes to the design as needed. Only when you are happy with the design do you then start coding the program from the design. You then use the debugger to make sure the program works as per the design. If the design is correct and the code correctly implements the design then the program will work.:cool: