Answer to Question #220080 in C++ for mame

Question #220080

Write a C++ application that can compute the letter grade of a student after accepting the student’s mid and final mark. The program should only accept mid result [0-40] and final [0- 60]. If the data entered violates thisrule, the program should display that the usershould enter the mark in the specified range. The program is also expected to run until the user refuses to continue. 


1
Expert's answer
2021-07-24T07:06:53-0400
#include<iostream>
using namespace std;
int main(){
	int final_mark;
	int mid_mark;
	cout<<"Enter the final mark . The final mark must be between 0 and 60\n";
	cin>>final_mark;
	while(final_mark > 60 || final_mark<0){
		cout<<"Invalid final mark\n. Enter mark within a specified range\n";
		exit(0);
		
	}
	cout<<"Enter the mid mark. The mid mark must between 0 and 40\n";
	cin>>mid_mark;
	while(mid_mark > 40 || mid_mark<0){
		cout<<"Invalid final mark. Enter mark within a specified range\n";
		exit(0);
	}
	int average = mid_mark + final_mark ;
	
	if(average >=70 && average< 100){
		cout<<"Grade is: A";
	}
	else if(average >=60 && average< 70){
		cout<<"Grade is: B";
	}
	else if(average >=50 && average< 60){
		cout<<"Grade is: C";
	}
	else if(average >=40 && average< 50){
		cout<<"Grade is: D";
	}
	else if(average >=0 && average< 40){
		cout<<"Grade is: Fail";
	}
	
	
	
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS