Question

In: Computer Science

Using C++. Write a program to input marks of five subjects Physics, Chemistry, Biology, Mathematics and...

Using C++. Write a program to input marks of five subjects Physics, Chemistry, Biology, Mathematics and Computer. The input marks must be inserted one subject at a time. The program then calculate percentage and grade according to given conditions:

If percentage >= 90% : Grade A

If percentage >= 80% : Grade B

If percentage >= 70% : Grade C

If percentage >= 60% : Grade D

If percentage >= 40% : Grade E

If percentage < 40% : Grade F

Example1: Please input marks of five subjects.

Physics: 95

Chemistry: 95

Biology: 97

Mathematics: 98

Computer: 90

Percentage = 95.00

Grade A

Example2: Please input marks of five subjects.

Physics: 85

Chemistry: 80

Biology: 95

Mathematics: 98

Computer: 70

Percentage = 85.60

Grade B

Solutions

Expert Solution

#include <iostream>
#include <iomanip>
using namespace std;
int main() {
    int n, sum = 0;
    
    double percentage;
    char grade;
    
   cout<<"Physics: ";
   cin>>n;
   sum += n;
   
   cout<<"Chemistry: ";
   cin>>n;
   sum += n;
   
   cout<<"Biology: ";
   cin>>n;
   sum += n;
   
   cout<<"Mathematics: ";
   cin>>n;
   sum += n;
   
   cout<<"Computer: ";
   cin>>n;
   sum += n;
   
   cout<<fixed<<setprecision(2);
   percentage  = sum/5.0;
   cout<<"Percentage = "<<percentage <<endl;
   
   if(percentage >= 90){
      grade = 'A';
   }
   else if(percentage >= 80){
      grade = 'B';
   }
   else if(percentage >= 70){
      grade = 'C';
   }
   else if(percentage >= 60){
      grade = 'D';
   }
   else if(percentage >= 40){
      grade = 'E';
   }
   else{
      grade = 'F';
   }
   
   cout<<"Grade "<<grade<<endl;
    return 0;
}


Related Solutions

Write a program to take input of scores for Chemistry, Biology and English for a student...
Write a program to take input of scores for Chemistry, Biology and English for a student and display the average with 2 decimal places if all of the three scores are in the range between 1 and 100 inclusive. Program should also display the course name for which scores are entered out of range telling Average couldn't be calculated. Following is a sample run: Enter scores for Chemistry, Biology and English between 1 and 100: 45 89 96 Avg score...
Living things are constrained by the laws of physics, chemistry, and mathematics. Provide two examples of...
Living things are constrained by the laws of physics, chemistry, and mathematics. Provide two examples of physical laws. - For each example explicitly name the law to explain what physiological processes are described by the law using specific examples. - explain why the limits of the laws constrain the function of animal bodies - - what does the law limit for each example?
There are 18 books on a shelf: 6 mathematics, 4 physics, 5 history, and 3 biology....
There are 18 books on a shelf: 6 mathematics, 4 physics, 5 history, and 3 biology. If Emil picks six books at random, what is the probability that he picks 3 mathematics,  2 physics and one other book?
Q20. Using C++ style string to write a program that reads a sentence as input and...
Q20. Using C++ style string to write a program that reads a sentence as input and converts each word of the sentence following the rule below: For every word in the sentence, the first letter is relocated the end of the word. Then append the string “KPU” to the word. More requirements: All letters in the output should be uppercase. More assumptions: The input sentence contains no non-alphabetic letters Sample Run: Please enter the original sentence: i LOVE to program...
Q20. Using C++ style string to write a program that reads a sentence as input and...
Q20. Using C++ style string to write a program that reads a sentence as input and converts each word of the sentence following the rule below: For every word in the sentence, the first letter is relocated the end of the word. Then append the string “KPU” to the word. More requirements: All letters in the output should be uppercase. More assumptions: The input sentence contains no non-alphabetic letters Sample Run: Please enter the original sentence: i LOVE to program...
Write a C++ Program Write a program that prompts the user to input a string. The...
Write a C++ Program Write a program that prompts the user to input a string. The program then uses the function substr to remove all the vowels from the string. For example, if str=”There”, then after removing all the vowels, str=”Thr”. After removing all the vowels, output the string. Your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel. You must insert the following comments at the beginning...
Write a C++ program to do the following USING ARRAYS 1) input 15 integers (input validation...
Write a C++ program to do the following USING ARRAYS 1) input 15 integers (input validation , all numbers must be between 0 and 100) 2) find the largest number 3) Find the Smallest Number 4) Find the Sum of all numbers in the Array Display: as per the user's section (menu using switch or if else ) Largest Number Smallest Number Sum of all numbers the original Array DO NOT USE METHODS OR FUNCTIONS Submit: Source code (C++) output...
An application of modeling with differential equations from a particular field, such as Physics,Biology, Business, Chemistry,...
An application of modeling with differential equations from a particular field, such as Physics,Biology, Business, Chemistry, etc.
ASSIGNMENT Compare and contrast the natural sciences (physics, chemistry, biology) with the behavioral and social sciences...
ASSIGNMENT Compare and contrast the natural sciences (physics, chemistry, biology) with the behavioral and social sciences (psychology, anthropology, economics, political science).
Write C++ mathematics program that a Given an arc with its center at zero, and the...
Write C++ mathematics program that a Given an arc with its center at zero, and the arc should be user defined in 3D-space by means of a 3x3 transformation matrix, and a radius, start-angle and sweep-angle should be user defined. it gives output/tells the most extreme XY points that arc goes to The radius,start angle and sweep angle should be user defined. make the code quickly and send me sir the matrix should always be 3x3 center is at zero...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT