Write a program that calculates the total grade for N classroom exercises as a percentage. The user should input the value for N followed by each of the N scores and totals. Calculate the overall percentage (sum of the total points earned divided by the total points possible) and output it as a percentage. Sample input and output is shown below. How many exercises to input? 3 Score received for exercise 1: 10 Total points possible for exercise 1: 10 Score received for exercise 2: 7
this is the
13.Write a program that calculates the total grade for N classroom exercises
as a percentage. The user should input the value for N followed by each of
the N scores and totals. Calculate the overall percentage (sum of the total
points earned divided by the total points possible) and output it as a percentage.
Sample input and output is shown below.
How many exercises to input? 3
Score received for exercise 1: 10
Total points possible for exercise 1: 10
Score received for exercise 2: 7
Total points possible for exercise 2: 12
Score received for exercise 3: 5
Total points possible for exercise 3: 8
Your total is 22 out of 30, or 73.33%.
my solution.
//declare variables
string exercise1;
string exercise2;
string exercise3;
string exercises;
string totalexercise1;
string totalexercise2;
string totalexercise3;
string yourtotal;
yourtotal = exercise1 + exercise2 + exercise3;
string outof;
outof = totalexercise1 + totalexercise2 + totalexercise3;
float total_points = 0;
float total_earned = 0;
//ask for user input
cout << "How many exercises to input :" << endl;
cin >> exercises;
cout << "Scores received for exercise 1 :" << endl;
cin >> exercise1;
cout << "Total points available for exercise 1 :" << endl;
cin >> totalexercise1;
cout << "Scores received for exercise 2 :" << endl;
cin >> exercise2;
cout << "Total points available for exercise 2 :" << endl;
cin >> totalexercise2;
cout << "Scores received for exercise 3 :" << endl;
cin >> exercise3;
cout << "Total points available for exercise 3 :" << endl;
cin >> totalexercise3;
outof = totalexercise1 + totalexercise2 + totalexercise3;
cout << "total out of :" << endl;
cout << " Yourtotal " << " outof :" << endl;
cin >> outof;
return 0;
}

Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images









