Take student name Take his homework 1 homework2 homework 3 a
Solution
Here is the code for you:
#include <iostream>
using namespace std;
int main()
{
//Take student name.
string name;
cout<<\"Enter the student name: \";
cin>>name;
//Take his 4 homework grades.
int hw1, hw2, hw3, hw4, qz1, qz2, qz3, qz4, midterm1, midterm2, finalexamGrade;
cout<<\"Enter the 4 homework grades: \";
cin>>hw1>>hw2>>hw3>>hw4;
//Take his 4 quiz grades.
cout<<\"Enter the 4 quiz grades: \";
cin>>qz1>>qz2>>qz3>>qz4;
//Take his 2 midterm grades.
cout<<\"Enter the 2 midterm grades: \";
cin>>midterm1>>midterm2;
//Take his final exam grade.
cout<<\"Enter the final exam grade: \";
cin>>finalexamGrade;
//Calculate the average of homework.
double homeworkAvg = (hw1 + hw2 + hw3 + hw4) / 4.0;
//Calculate the average of quiz.
double quizAvg = (qz1 + qz2 + qz3 + qz4) / 4.0;
//Calculate the final exam grade.
double finalGrade = homeworkAvg * 0.10 + quizAvg * 0.10 + midterm1 * 0.20 + midterm2 * 0.20 + finalexamGrade * 0.40;
//Output the student name.
cout<<\"Student name: \"<<name<<endl;
//Output the final grade.
cout<<\"Final grade: \"<<finalGrade<<endl;
//Output word Pass if the grade equal and more than 60, and output word failed if the grade less than 60.
if(finalGrade >= 60)
cout<<\"Pass\"<<endl;
else
cout<<\"Failed\"<<endl;
}
