Question

C++ Write a program that calculates and prints the total grade for n assignments as a...

C++

Write a program that calculates and prints the total grade for n assignments
as a percentage. Prompt the user to enter the value of n, followed by the number
of points received and number of points possible for each assignment . Calculate
and print the total number of points received, total number of points possible,
and the overall percentage: (total points received / total points possible) * 100.

Output:

Enter·number·of·assignments·to·input:3↵

Enter·number·of·points·received·for·assignment·1 :10↵

Enter·number·of·possible·points·for·assignment·1 :10↵

Enter·number·of·points·received·for·assignment·2 :7↵

Enter·number·of·possible·points·for·assignment·2 :12↵

Enter·number·of·points·received·for·assignment·3 :5↵

Enter·number·of·possible·points·for·assignment·3 :8↵

our·total·amount·of·points·is·22·out·of·30,·or·73.33%.↵

Homework Answers

Answer #1

Program:

#include<iostream>
#include<iomanip>
using namespace std;

int main()
{
   int n;
   int totalPointsReceived=0, totalPointsPossible=0;
   double overallPercentage;
   int pointsReceived,pointsPossible;
  
   //prompt and read the number of assignments
   cout<<"\nEnter number of assignments to input: ";
   cin>>n;
  
   //run a loop to read n number of point
   for(int i=0;i<n;i++)
   {
       //prompt and read points received
       cout<<"\nEnter number of points received for assignment "<<(i+1)<<" : ";
       cin>>pointsReceived;
      
       //prompt and read points possible
       cout<<"\nEnter number of possible points for assignment "<<(i+1)<<" : ";
       cin>>pointsPossible;
      
       //add the points to totalPointsReceived
       totalPointsReceived=totalPointsReceived+pointsReceived;
      
       //add the points to totalPointsPossible
       totalPointsPossible=totalPointsPossible+pointsPossible;
   }
  
   //calculate the overall percentage
   overallPercentage = ((double)totalPointsReceived / (double)totalPointsPossible) * 100.00;
  
   //print the output
   cout<<"\nOur total amount of points is "<<totalPointsReceived<<" out of "<<totalPointsPossible<<" or "<<setprecision(4)<<overallPercentage<<"%";
   return 0;
}

Output:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
1)Write a program that asks a user for a number. If (and only if) the number...
1)Write a program that asks a user for a number. If (and only if) the number is greater than zero print “The number is valid” 2)Write a program that asks a user for a grade. If (and only if) the grade is greater than zero and less than 101, print “The grade is valid” 3)Write a program that asks a user how many widgets they want to buy and prints out what the user should pay. Widgets costs 10 dollars....
Write a C++ program with a user-defined function myFactorial, that calculates the factorial of a number...
Write a C++ program with a user-defined function myFactorial, that calculates the factorial of a number entered by the user. Return the calculated factorial and print it in the main function.
Write a program that asks the user to enter an odd number and prints out a...
Write a program that asks the user to enter an odd number and prints out a triangle pattern. For example, if the user enters 5, the output is note: There is one space between the numbers in each line 1 3 5 1 3 1 If the user enters 9 the output is: 1 3 5 7 9 1 3 5 7 1 3 5 1 3 1 program language: C++
Please use Python 3 4). Write a program that asks the user to enter 10 numbers....
Please use Python 3 4). Write a program that asks the user to enter 10 numbers. The program should store the numbers in a list and then display the following data: • The lowest number in the list • The highest number in the list •The total of the numbers in the list • The average of the numbers in the list   Sample input & output: (Prompt) Enter Number 1: (User enter) 4 (Prompt) Enter Number 2: (User enter) 7...
in c++ Write a C++ program that asks the user to enter an integer number and...
in c++ Write a C++ program that asks the user to enter an integer number and prints it back "vertically" to the screen. Use recursion in your solution. As an example of how the program will work: Please enter an integer: 12345 The integer you entered will print vertically as: 1 2 3 4 5
C++ PROBLEM: Create a program that calculates the hyperfactorial of any positive integer n, where the...
C++ PROBLEM: Create a program that calculates the hyperfactorial of any positive integer n, where the hyperfactorial is equivalent to value obtained by the operation: 1^1*2^2*3^3*…..n^n . If user inputs the value that is not a positive value, display a message informing the user that the input is not valid and request a new input. Calculate the hyperfactorial first by creating a program that uses only nested “For loop” structure.
**C code only In this part, you will write a simple user-defined function that prints a...
**C code only In this part, you will write a simple user-defined function that prints a message. This function does not require any parameters or return value. The purpose is simply to get you started writing functions.Open repl project Lab: User-Defined Functions 1. Write a program that calls a function. This function should do the following: 1.Ask the user their name 2. Print a "hello" message that includes the user's name Example output: Please enter your name: ​Mat Hello, Mat!...
Using python, write the program below. Program Specifications: You are to write the source code and...
Using python, write the program below. Program Specifications: You are to write the source code and design tool for the following specification: A student enters an assignment score (as a floating-point value). The assignment score must be between 0 and 100. The program will enforce the domain of an assignment score. Once the score has been validated, the program will display the score followed by the appropriate letter grade (assume a 10-point grading scale). The score will be displayed as...
In C programming language write a function that takes an integer n as input and prints...
In C programming language write a function that takes an integer n as input and prints the following pattern on the screen: 1 (n times) 2 (n-1 times) .n (1 time) For example, if n was 5, the function should print 1 1 1 1 1 2 2 2 2 3 3 3 4 4 5
Write a complete recursive java program to compute the heights of the tick marks on a...
Write a complete recursive java program to compute the heights of the tick marks on a ruler. Assume that the length of the ruler is a power of 2 (say L=2^n, where n >=1) , and the marks are to be placed at every point between 0 and 2^n, not including the endpoints. The endpoints 0 and 2^n will have height 0. Here are the rules for computing the heights of the ticks for a ruler of length L=2^n: 1....