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

C++ Please keep and solve TODO sections. Match the sample output. This program w

ID: 3910021 • Letter: C

Question

C++ Please keep and solve TODO sections. Match the sample output.

This program will calculate the average of multiple assignment scores.

Write a program that asks the user to enter their scores (along with the max

score) for numerous assignments. The user should be allowed to enter as many

scores as they like and each user entry must be validated.

*/

#include <iostream>

#include <iomanip>

using namespace std;

int main()

{

// TODO STEP 1: Declare 8 variables:

// - type int, to hold the user's entry for the maximum points of one assignment

// - type int, to hold the user's entry for the actual points earned for a single assignment

// - type int, COUNTER to store the number of assignments the user has entered

// - type int, to ACCUMULATE the total possible points for ALL assignments entered

// - type int, to ACCUMULATE the total points earned by the student for ALL assignments entered

// - type char, holds user's answer on whether they want to enter more assignments

// - type double, to hold the calculated average

// - type char, to hold the student's final letter grade

//

// Initialize any variables above, as necessary - ONLY the ones that are necessary

//

// NOTE: Points will be deducted for poorly named variables - variables must be

// named so it is easy to know what the purpose of the variable is

// BAD EXAMPLES: var1, variable1, num, number, int1, data, aChar, x, a, b, c, and MANY MORE

/* TODO - Step 2

Begin a loop here. The purpose of this loop is to repeat each time the user tells you

they want to enter more assignment values. This loop should ALWAYS execute at least once.

Make sure you use the correct type of loop (for, while, do...while) to meet these specs.

After you have started the loop here, scroll DOWN (after STEP 9, before STEP 10) to put the end of this loop!

*/

{

// TODO STEP 3: The user is entering max and actual points for another assignment,

// so increment the counter keeping track of how many scores have been entered.

// TODO STEP 4: Output the assignment header (with proper assignment number)

// (look at the SAMPLE OUTPUT below and make your solution match)

//

// Data for Assignment #X

// =======================

// TODO STEP 5: Prompt the user and get the maximum points for the current assignment

// (look at the SAMPLE OUTPUT below and make your solution match).

// TODO STEP 6: Write a loop to validate that the user entered a number between 1 to 100

// Display an error message if the user made an incorrect entry and prompt them to make

// a new entry. Be sure to use the type of loop best suited for this circumstance, where

// the user may make zero or more mistakes (though the exact number is not known) before

// finally entering a value that falls in the correct range. Once again, refer to the

// SAMPLE OUTPUT below to determine the correct formatting of the error message.

cout << endl;

// TODO STEP 7: Now that a valid value for max points has been entered, add it to the

// appropriate accumulator variable.

// TODO STEP 8: Prompt the user and get the actual points earned for the current assignment

// (look at the SAMPLE OUTPUT below and make your solution matches).

// TODO STEP 9: Write a loop to validate that the user entered a number between 0 to 100

// Display an error message if the user made and incorrect entry and prompt them to make

// a new entry. Be sure to use the type of loop best suited for this circumstance, where

// the user may make zero or more mistakes (though the exact number is not known) before

// finally entering a value that falls in the correct range. Once again, refer to the

// SAMPLE OUTPUT below to determine the correct formatting of the error message.

cout << endl;

// TODO STEP 10: Now that a valid value for the student's score has been entered, add it

// to the appropriate accumulator variable.

// TODO STEP 11: Prompt the user, asking if they want to enter info for another assignment

// (look at the SAMPLE OUTPUT below and make your solution matches).

// TODO - COMPLETION OF STEP 2 - finish the loop statement started above in Step 2

}

// TODO STEP 12: Calculate the average of all the assignments and assign the result to the

// proper variable.

//

// NOTE: Make sure the decimal part of the answer is NOT lost

// NOTE: Multiply by 100, 0.890735 should be 89.0735%

// TODO STEP 13: Determine the student's letter grade - assign the result to the proper variable

//

// NOTE 1: Use an if...else if...else if...etc.

// NOTE 2: Be careful to use, or don't use, = properly

// NOTE 3: 90 and above is an A, etc. -- DO NOT test 89, 79, 69, etc.

// TODO STEP 14: Display the student's average and grade - matching the format in Sample Output

//

// NOTE: NO setw required, other io manipulators MAY be required

return 0;

}

/*

************************* SAMPLE OUTPUT *******************************

Data for Assignment #1

=======================

Enter max points: 0

ERROR: Max points must be 1 - 100 - REENTER: -1

ERROR: Max points must be 1 - 100 - REENTER: 100

Points earned: -1

ERROR: Points earned must be 0 - 100 - REENTER: 83

Do you want to enter more assignments? (Y/N): y

Data for Assignment #2

=======================

Enter max points: 50

Points earned: 45

Do you want to enter more assignments? (Y/N): Y

Data for Assignment #3

=======================

Enter max points: 10

Points earned: -1

ERROR: Points earned must be 0 - 100 - REENTER: 0

Do you want to enter more assignments? (Y/N): y

Data for Assignment #4

=======================

Enter max points: 20

Points earned: 17

Do you want to enter more assignments? (Y/N): n

Final Results

=============

Number of assignments averaged: 4

Average = 80.5556%

Grade = B

Press any key to continue . . .

*/

Explanation / Answer

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
// TODO STEP 1: Declare 8 variables:
int maxPoints; // to hold the user's entry for the maximum points of one assignment
int pointsEarned; // hold the user's entry for the actual points earned for a single assignment
int countAssignments;   // - type int, COUNTER to store the number of assignments the user has entered
int totalPoints; // - type int, to ACCUMULATE the total possible points for ALL assignments entered
int totalPointsEarned; // - type int, to ACCUMULATE the total points earned by the student for ALL assignments entered
char option; // - type char, holds user's answer on whether they want to enter more assignments
double avg; // - type double, to hold the calculated average
char grade; // - type char, to hold the student's final letter grade
//
// Initialize any variables above, as necessary - ONLY the ones that are necessary
//
countAssignments = 0;
totalPoints = 0;
totalPointsEarned = 0;
avg = 0.0;
grade = 'o';

/* TODO - Step 2
Begin a loop here. The purpose of this loop is to repeat each time the user tells you
they want to enter more assignment values. This loop should ALWAYS execute at least once.
Make sure you use the correct type of loop (for, while, do...while) to meet these specs.
After you have started the loop here, scroll DOWN (after STEP 9, before STEP 10) to put the end of this loop!
*/

do
{
// TODO STEP 3: The user is entering max and actual points for another assignment,
// so increment the counter keeping track of how many scores have been entered.
// TODO STEP 4: Output the assignment header (with proper assignment number)
// (look at the SAMPLE OUTPUT below and make your solution match)
//
countAssignments++;
cout<<" Data for Assignment #"<<countAssignments;
cout<<" =======================";
// TODO STEP 5: Prompt the user and get the maximum points for the current assignment
// (look at the SAMPLE OUTPUT below and make your solution match).
cout<<" Enter max points : ";
cin>>maxPoints;

// TODO STEP 6: Write a loop to validate that the user entered a number between 1 to 100
// Display an error message if the user made an incorrect entry and prompt them to make
// a new entry. Be sure to use the type of loop best suited for this circumstance, where
// the user may make zero or more mistakes (though the exact number is not known) before
// finally entering a value that falls in the correct range. Once again, refer to the
// SAMPLE OUTPUT below to determine the correct formatting of the error message.


while(maxPoints <= 0)
{

cout<<" ERROR: Max points must be in 1-100 - REENTER : ";
cin>>maxPoints;

}

// TODO STEP 7: Now that a valid value for max points has been entered, add it to the
// appropriate accumulator variable.
totalPoints = totalPoints + maxPoints;

// TODO STEP 8: Prompt the user and get the actual points earned for the current assignment
// (look at the SAMPLE OUTPUT below and make your solution matches).
cout<<" Points earned : ";
cin>> pointsEarned;

// TODO STEP 9: Write a loop to validate that the user entered a number between 0 to 100
// Display an error message if the user made and incorrect entry and prompt them to make
// a new entry. Be sure to use the type of loop best suited for this circumstance, where
// the user may make zero or more mistakes (though the exact number is not known) before
// finally entering a value that falls in the correct range. Once again, refer to the
// SAMPLE OUTPUT below to determine the correct formatting of the error message.
cout << endl;

while(pointsEarned < 0)
{
cout<<" ERROR: Points earned must be in 0-100 - REENTER : ";
cin>>pointsEarned;

}

// TODO STEP 10: Now that a valid value for the student's score has been entered, add it
// to the appropriate accumulator variable.
totalPointsEarned = totalPointsEarned + pointsEarned;

// TODO STEP 11: Prompt the user, asking if they want to enter info for another assignment
// (look at the SAMPLE OUTPUT below and make your solution matches).
cout<<" Do you want to enter more assignments? (y/n):";
cin>>option;
if(option != 'y')
break;
// TODO - COMPLETION OF STEP 2 - finish the loop statement started above in Step 2
}while(option == 'y');

// TODO STEP 12: Calculate the average of all the assignments and assign the result to the
// proper variable.
//
// NOTE: Make sure the decimal part of the answer is NOT lost
// NOTE: Multiply by 100, 0.890735 should be 89.0735%
avg = (double)totalPointsEarned/totalPoints*100;

// TODO STEP 13: Determine the student's letter grade - assign the result to the proper variable
//
// NOTE 1: Use an if...else if...else if...etc.
// NOTE 2: Be careful to use, or don't use, = properly
// NOTE 3: 90 and above is an A, etc. -- DO NOT test 89, 79, 69, etc.
if(avg >= 90)
grade = 'A';
else if(avg >= 80)
grade = 'B';
else if(avg >= 70)
grade = 'C';
else if(avg >= 60)
grade = 'D';
else if(avg >= 50)
grade = 'E';
else
grade = 'F';

// TODO STEP 14: Display the student's average and grade - matching the format in Sample Output
//
// NOTE: NO setw required, other io manipulators MAY be required

cout<<" Final Results";
cout<<" =============";
cout<<" Number of assignments averaged: "<<countAssignments;
cout<<" Average = "<<avg<<"%";
cout<<" Grade = "<<grade;


return 0;
}

Output:

Data for Assignment #1
=======================
Enter max points :0
ERROR: Max points must be in 1-100 - REENTER :-1
ERROR: Max points must be in 1-100 - REENTER :100
Points earned :-1

ERROR: Points earned must be in 0-100 - REENTER :83
Do you want to enter more assignments? (y/n):y
Data for Assignment #2
=======================
Enter max points :50
Points earned :45

Do you want to enter more assignments? (y/n):y
Data for Assignment #3
=======================
Enter max points :10
Points earned :-1

ERROR: Points earned must be in 0-100 - REENTER :0
Do you want to enter more assignments? (y/n):y
Data for Assignment #4
=======================
Enter max points :20
Points earned :17

Do you want to enter more assignments? (y/n):n

Do ask if any doubt. Please upvote.
Final Results
=============
Number of assignments averaged: 4
Average = 80.5556%
Grade = B

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