Grades
-
Use an input file An instructor has asked you to write a program that can tell him if his students have passed or failed his course. He has a file that contains the following information: • first name • last name • five quiz grades • the midterm exam grade • the final exam grade Your program must read these values into variables then use those variables to calculate the final average and finally display that average to the screen. Requirements: 1. All input comes from a file – grades.txt. You may NOT ask for input from the professor. This file is posted on Canvas for your program to use. 2. Remember: Your program must calculate the final average including those quizzes. All the quizzes averaged together count as much as a test. So, to calculate the final, you need to calculate the quiz average first, then average the midterm + final + quiz average. 3. Display the student’s last name first, comma, space and first name. Follow that with the final average as a whole number, rounded up The file contains one line of data in the following order: firstName lastName q1 q2 q3 q4 q5 midterm final Remember, data must be read in sequentially! This means that the first name variable must be initialized before the last name or the quiz one and etc. Code: #include #include using namespace std; /* run this prgram using the console pauser or add your own getch, system('pause") or input look */ int main(int argc, char** argv) { string firstName,lastName; int q1, q2, q3, q4, q5, midterm, final; int quizaverage; int average; ifstream inFile; inFile.open("grades.txt"); inFile>>firstName>>lastName>>q1>>q2>>q3>>q4>>q5>>midterm>>final; //Calculate the quiz average. quizaverage=(q1+q2+q3+q4+q5)/5; average=(quizaverage+midterm+final)/3*100; cout<<"Dobbs, Bob"<<" Average: "<
-
Use an input file An instructor has asked you to write a program that can tell him if his students have passed or failed his course. He has a file that contains the following information: • first name • last name • five quiz grades • the midterm exam grade • the final exam grade Your program must read these values into variables then use those variables to calculate the final average and finally display that average to the screen. Requirements: 1. All input comes from a file – grades.txt. You may NOT ask for input from the professor. This file is posted on Canvas for your program to use. 2. Remember: Your program must calculate the final average including those quizzes. All the quizzes averaged together count as much as a test. So, to calculate the final, you need to calculate the quiz average first, then average the midterm + final + quiz average. 3. Display the student’s last name first, comma, space and first name. Follow that with the final average as a whole number, rounded up The file contains one line of data in the following order: firstName lastName q1 q2 q3 q4 q5 midterm final Remember, data must be read in sequentially! This means that the first name variable must be initialized before the last name or the quiz one and etc. Code: #include #include using namespace std; /* run this prgram using the console pauser or add your own getch, system('pause") or input look */ int main(int argc, char** argv) { string firstName,lastName; int q1, q2, q3, q4, q5, midterm, final; int quizaverage; int average; ifstream inFile; inFile.open("grades.txt"); inFile>>firstName>>lastName>>q1>>q2>>q3>>q4>>q5>>midterm>>final; //Calculate the quiz average. quizaverage=(q1+q2+q3+q4+q5)/5; average=(quizaverage+midterm+final)/3*100; cout<<"Dobbs, Bob"<<" Average: "<
-
I need to use an input file to find that course average. The course average is a mathematical expression involved in quiz average, midterm grade, and final grade. I am trying to get the program to read what is in the file. There is the first name, last name, and 7 numbers. I need to use these values in the program to get an average for the class.
-
I need to use an input file to find that course average. The course average is a mathematical expression involved in quiz average, midterm grade, and final grade. I am trying to get the program to read what is in the file. There is the first name, last name, and 7 numbers. I need to use these values in the program to get an average for the class.
-
I need to use an input file to find that course average. The course average is a mathematical expression involved in quiz average, midterm grade, and final grade. I am trying to get the program to read what is in the file. There is the first name, last name, and 7 numbers. I need to use these values in the program to get an average for the class.
How are your results different from what is expected? Also, showing the files exact contents would be helpful.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle