how would you write a program, using the C++ language, that uses only for and wh
ID: 3617323 • Letter: H
Question
how would you write a program, using the C++ language, that uses only for and while loops to read in ten scores, separated by spaces, from an input file. It needs to alot for any number of spaces in between the numbers and anywhere from 0 to 10 numbers. The general idea is averaging quiz scores for a whole class in one go. So, it needs to be able to read in like 25-30 of these lines consecutively. I know generally how to do everything except for the actual loop coding itself. Any help would be appreciated.Explanation / Answer
please rate - thanks // ***************************** //Program Title: Project_08 //Project File: Project_08.cpp //Name: Bryan Britt //Course Section: CPE-112-02 //Lab Section: 4 //Due Date: 12/3/2010 //Description: Open an input file containing a student's name andten quiz //grades, all separated by spaces, or multiple spaces. Take theaverage of all of //the quiz grades, even if less than ten are provided, then assignan appropriate //letter grade. This must be repeated until there are no more linesin the input //file. The output is to a user specified text file. //If nothing is in the input file, print nothing. // ***************************** #include #include #include #include #include using namespace std; int main () { //Variables int count, num, sum; float avg; char letter,nl; string first, last; string input, output; string end_test; //Filestreams ifstream infile; ofstream outfile; cout > input; infile.open(input.c_str()); cout > output; outfile.open(output.c_str()); //Logic Loops infile>>last; while(infile) { sum=0; infile>>first; outfileRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.