Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that reads a student Solution 001 #include 002 #include 003 #inc

ID: 440393 • Letter: W

Question

Write a program that reads a student

Explanation / Answer

001 #include 002 #include 003 #include 004 #include 005 #include 006 007 008 009 usingnamespacestd; 010 011 012 //user defined function, calculates the average of five test scores. 013 doublecalculateAverage(doubletest1, doubletest2, doubletest3, doubletest4, doubletest5); 014 015 016 //user defined function. takes the average test scores and returns the letter grade. 017 charcalculateGrade(doubleaverage); 018 019 020 021 //calculate the average score 022 doublecalculateAverage(doubletest1, doubletest2, doubletest3, doubletest4, doubletest5) 023 { 024 025     intaverage; 026 027     average=(test1+test2+test3+test4+test5)/5; //add the test scores and divide by the number of tests. 028 029     returnaverage; //return the average of the five tests. 030 031 } 032 033 034 //assign a letter grade 035 charcalculateGrade(doubleaverage) 036 037 { 038     chargrade; 039 040     if(average >= 90) 041 042         grade='A'; 043 044     elseif(average>=80) 045 046         grade='B'; 047 048     elseif(average>=70) 049 050         grade='C'; 051 052     elseif(average>=60) 053 054         grade='D'; 055 056     else 057 058         grade='F'; 059 060     returngrade; 061 062 } 063 064 065 intmain() 066 { 067 068     doubletest1, test2, test3, test4, test5; //using the same variables as the average calculator 069     doubleaverage; 070     doubleclassaverage=0; //set class average to zero for latter update 071     doublecount=0;   //set count to zero for later update 072 073     chargrade; //letter grade to be returned by the calculateGrade function 074 075     string name;   //name to be taken from a file later specified 076 077     ifstream infile;  //creates an operator that extracts input from a file 078     ofstream outfile; //creates an operator that prints output to a file 079 080 081     infile.open("c:\testScores.txt"); //opens the file including the test scores. 082     outfile.open("c:\averages.txt");  //creates a file for average and grade output 083 084     outfile
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote