Answer to Question #317196 in C++ for Micheal

Question #317196

Write a program to ask the user to input a value representing a score on a test. The value entered should be between 0 and 100. Use a IF control structure to output a message containing the letter grade corresponding to the score using the following table.

Score Letter grade

0-40 F

41-55 D

56-70 C

71-85 B

86-100 A


1
Expert's answer
2022-03-24T01:40:20-0400
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;




int main(void){
	int score;


	cout<<"Enter score between 0 and 100: ";
	cin>>score;
	//0-40 F
	if(score>=0 && score<=40){
		cout<<"Letter grade: F\n";
	}
	//41-55 D
	else if(score>=41 && score<=55){
		cout<<"Letter grade: D\n";
	}
	//56-70 C
	else if(score>=56 && score<=70){
		cout<<"Letter grade: C\n";
	}
	//71-85 B
	else if(score>=71 && score<=85){
		cout<<"Letter grade: B\n";
	}
	//86-100 A
	else if(score>=86 && score<=100){
		cout<<"Letter grade: A\n";
	}else{
		cout<<"Wrong score\n";
	}
	system("pause");
	return 0;
}

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