rework my program in c to use loops- Savvy Essay Writers | savvyessaywriters.net

rework my program in c to use loops- Savvy Essay Writers | savvyessaywriters.net

I need help to rework my original code using either while, do- while, or for loops. I also need to use an array to calculate the quiz avg and the lowest quiz grade should be dropped. I’m not sure exactly where to edit the code to add these loops.

Here is my original code:

#include <iostream>
using namespace std;

char getGrade(int score)
{
if (score >= 89.5)
return ‘A’;
else if (score >= 79.5)
return ‘B’;
else if (score >= 69.5)
return ‘C’;
else if (score >= 59.5)
return ‘D’;
else
return ‘F’;
}

float Exams()
{
float Ex1, Ex2, Ex3, Ex;
cout << “Please input three exam grades : “;
cin >> Ex1 >> Ex2 >> Ex3;
Ex = (Ex1 + Ex2 + Ex3) / 3.0;
cout << endl;
cout << “n Exam 1 = ” << Ex1 << endl
<< “n Exam 2 = ” << Ex2 << endl
<< ” n Exam 3 = ” << Ex3 << endl
<< endl
<< “Exam grade = ” << getGrade(Ex) << endl;
cout << endl;
return Ex;

}

float Labs()
{
float Lb1, Lb2, Lb3, Lb;
cout << “Please input three lab grades : “;
cin >> Lb1 >> Lb2 >> Lb3;
Lb = (Lb1 + Lb2 + Lb3) / 3.0;
cout << “n Lab 1 = ” << Lb1 << endl
<< ” n Lab 2 = ” << Lb2 << endl
<< ” n Lab 3 = ” << Lb3 << endl
<< endl
<< “Lab Grade = ” << getGrade(Lb);
cout << endl;
return Lb;

}
float Project()
{
float Proj;
cout << “Please input project grade : “;
cin >> Proj;
cout << “Project = ” << Proj << endl;
cout << “Project grade = ” << getGrade(Proj) << endl;
cout << endl;
return Proj;
}

float Quizzes()
{
float Qz1, Qz2, Qz3, Qz;
cout << “Please input three quiz grades : “;
cin >> Qz1 >> Qz2 >> Qz3;
Qz = (Qz1 + Qz2 + Qz3) / 3.0;
cout << endl
<< “n Quiz 1 = ” << Qz1 << endl
<< ” n Quiz 2 = ” << Qz2 << endl
<< “n Quiz 3 = ” << Qz3 << endl
<< endl
<< “Quiz grade = ” << getGrade(Qz) << endl;
cout << endl;
return Qz;
}
//This function prints final grade with avgs
void final(float Ex, float Lb, float Proj, float Qz)
{
float Final;
Final = Ex * 0.3 + Lb * 0.3 + Proj * 0.3 + Qz * 0.1;
cout << endl
<< “Final score = ” << Final << endl;
cout << “Final Grade = ” << getGrade(Final) << endl;
}

//main function
int main() {
//taking the inputs from user
string Fname, Lname, course, semester;
float Ex, Lb, Proj, Qz;
cout << “Enter full name : ” << endl;
cin >> Fname >> Lname;
cout << “Enter course name : ” << endl;
cin >> course;
cout << “Enter semester ” << endl;
cin >> semester;
//printing the details entered by user
cout << “Name : ” << Fname << Lname << endl;
cout << “Course : ” << course << endl;
cout << “Semester : ” << semester << “n” << endl;
//calling all functions
Ex = Exams();
Lb = Labs();
Proj = Project();
Qz = Quizzes();
final(Ex, Lb, Proj, Qz);
return 0;
}

Savvy Essay Writers

Place your order Now