yeah, but back then it was c+p = copy + paste
yes i do
you had/have the class?
yeah, but back then it was c+p = copy + paste
PM or ask Baseline_Bum, he's a genius when it comes to programming/mathematics.
Well, 90% of programming (at least, of the beginning sort) is copying what you need from a program that is close to what you want to do. Your textbook would/should have examples of reading in and printing out information. Maybe you have online notes that you can look at for this purpose.
Anyway, to give some help, you should first write a program that can open the input file, read the individual items from one line, print them out again, and close the input file. Then you'll need to put the read and print parts in a loop so they'll get done multiple times. Next, you will need to open and print to the output file. Finally, you'll need an if or a switch statement to count the grades, which you will print out after the loop. I assume because you are supposed to use a count loop that you can assume that there are a certain number of lines in the input file.
Or use a "while not eof" condition...
"asshole" is a college professor ... you might want to be a little nicer.![]()
That sounds like the same assignment I had 20 years ago!![]()
Me, too ... writing in Pascal.![]()
Why would you use a count loop for reading in input from a file? The only way it would work is if you knew exactly how many records you had to read in beforehand. Even if you did, it's just as easy to do something like...
where is is the input stream you're reading from, sid is a std::string representing the student ID, lgr could be of an enumeration type with values {A,B,C,D,F}, and avg could be a float or an int, depending on how the grader stored it. There's no need to know how many records there are in this case, assuming each record is entered correctly in the prog5input.txt file. It's a much more flexible solution to just keep reading until you hit the end of the file, using the above code block.Code:while (is >> sid ) { is >> avg; is >> lgr; /* do other stuff */ }
There are currently 1 users browsing this thread. (0 members and 1 guests)