Question

C++ Write a program which accepts a numeric test score from the user. It will output...

C++

Write a program which accepts a numeric test score from the user. It will output the letter grade to the user corresponding to the score. Assume no “minus grades” (an A ranges from 90-100, B ranges from 80-89, C ranges from 70-79, D ranges from 60-69 and F is everything else.) Ensure that the score remains in the range of 0 to 100. As an example of the output:

   Enter your numeric grade and I will tell you your output: 74
   Your grade is a C.

Homework Answers

Answer #1
#include <iostream>

using namespace std;

char getLetterGrade(double average){
   char letter;
   if(average < 60)
        letter = 'F';
    else if(average < 70)
        letter = 'D';
    else if(average < 80)
        letter = 'C';
    else if(average < 90)
        letter = 'B';
    else
        letter = 'A';
    return letter;
}

int main(){
   double averageScore;
   cout<<"Enter your numeric grade and I will tell you your output: ";
    cin>>averageScore;
    cout<<"Your grade is a "<<getLetterGrade(averageScore)<<"."<<endl;
    return 0;
}
   

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
Write a program that keeps reading a test score until a -1 is entered. The program...
Write a program that keeps reading a test score until a -1 is entered. The program will output the letter grade according to the table below: Score Grade 90-100.   A 80-89.   B 70-79.   C 60-69.   D < 60.   F For example: Enter a Score (-1 to Exit): 92 The Letter grade for that score is A. Enter a Score (-1 to Exit): -1
C++ Write a program which accepts a character from the user. If the character is between...
C++ Write a program which accepts a character from the user. If the character is between 0 and 9, it will output that it's a digit. If the character is lowercase it will output that its a lowercase character. If it's an uppercase character it will output that it's uppercase. For all other cases it will output that it's neither a digit nor a letter. As an example of the output: Enter a digit or a letter: A You entered...
-- 3. Create a variable to store a numeric grade -- Write a CASE statement that...
-- 3. Create a variable to store a numeric grade -- Write a CASE statement that uses the variable to calculate a letter grade -- If the numeric grade is above 100 or below 0, return "Invalid grade" -- A = 90-100, B = 80-89, C = 70-79, D = 60-69, F = 0-59 -- Hint: SELECT doesn't always require a FROM clause
Write a program using Matlab that asks the user for their last three grades and final...
Write a program using Matlab that asks the user for their last three grades and final grade and gives them their overall final grade. The three Midterms are worth 70% and Final is worth 30%. The program will display their Final grade with a grade letter corresponding to it. Run your program and verify that it operates correctly (hint: you might need to use “If, else statements”)
Write a Java program to display a letter grade based on an actual grade. USING ECLIPSE...
Write a Java program to display a letter grade based on an actual grade. USING ECLIPSE IDE A = 90-100 B = 80-89 C = 70-79 D = 60-69 F = less than 60 The program needs to do the following: 1. Create a short integer to store a grade. (See Week 3 - Things to Know - Java Data Types ) 2. Prompt for a grade ( 0-100). 3. Based on the grade given, use IF statements to display...
Create a Grade application that prompts the user for the percentage earned on a test or...
Create a Grade application that prompts the user for the percentage earned on a test or other graded work and then displays the corresponding letter grade. The application should use the grading scale at your school or the following grading scale: 90 – 100 A 80 – 89 B 70 – 79 C 60 – 69 D below 60 F The application output should look similar to: Enter your marks: 90 Grade: A Notes: coded in java. Please don't make...
C++ [Program-2] Write a program that accepts an indefinite set of numbers until the user enters...
C++ [Program-2] Write a program that accepts an indefinite set of numbers until the user enters “-1”. In other words, the program keeps accepting new values until the user provides a “-1” (your program accepts all values, and discards the “-1”). When done, the program prints back to the user: (i) the sum of all numbers entered (except -1), (ii) the minimum value seen across all numbers (except -1), and (iii) the maximum value across all numbers (except -1).
Write a function, grade(score), which is given score, and it returns a letter grade — the...
Write a function, grade(score), which is given score, and it returns a letter grade — the grade for that mark — according to this scheme: A: >= 90 B: [80, 90) C: [70, 80) D: [60, 70) F: < 60 The square and round brackets denote closed and open intervals. A closed interval includes the number, and an open interval excludes it. So 79.99999 gets grade C, but 80 gets grade B. Define the main function as follows: In main,...
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 JAVA 1. Write up a small program that accepts two integers from the user. Print...
IN JAVA 1. Write up a small program that accepts two integers from the user. Print which of the two values is bigger. If they are the same, print that they are the same. 2. Write a method that accepts three doubles. Calculate and return the average of the three passed double values. 3. Write up a method that accepts a score between 0-10. Print out a message according to the following table. You ay personally decide the boundaries. i.e.,...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT