Question

Write a program that asks the user for their grade (integers only from 0-100). Depending on the grade number, assign a letter grade. Le. 0.50: F, 51.65: D, 6675: C, 76-85: B, 86-100: A. Use nested conditionals here. (Be sure to convert the string! Bonus: how would you handle cases where the user enters-1 or 101?)
0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <stdio.h>

int main()
{
   char letter;
   int score = 0;
   do{
      if(!(score>=0 && score<=100)){
         printf("Invalid input\n");
      }
      printf("Enter score: ");
      scanf("%d",&score);
   }while(!(score>=0 && score<=100));
   if(score < 50)
        letter = 'F';
    else if(score < 65)
        letter = 'D';
    else if(score < 75)
        letter = 'C';
    else if(score < 85)
        letter = 'B';
    else
        letter = 'A';
    printf("\nLetter grade = %c\n",letter);
    return 0;
}

Enter score:-567 Invalid input nter score: 567 Invalid input Enter score: 90 Letter grade A Process exited after 5.172 seconds with returnvalue 0 Press any key to continue - - -

\color{blue}Please\; up\;vote\;the \;solution \;if \;it \;helped.\;Thanks!

Add a comment
Know the answer?
Add Answer to:
Write a program that asks the user for their grade (integers only from 0-100). Depending on...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Java programming only Create a Java program that inputs a grade from the user. The grade input from the user will be an...

    Java programming only Create a Java program that inputs a grade from the user. The grade input from the user will be an integer. Once the input is stored, use an if-else-if block of code to determine the letter grade of the inputted integer grade. Do not use a bunch of if statements by themselves to solve this problem. You will print an error message for inputs greater than 100 and for inputs less than 0. Both errors must be...

  • Write a program in JAVA that asks the user to enter an integer. Store the integers...

    Write a program in JAVA that asks the user to enter an integer. Store the integers in an array. Allow for up to 10 integers. When the user enters -1, the program should end. Print the number of integers entered as well as the number of times each integer was entered.

  • Part I Create a Java program that inputs a grade from the user. The grade input...

    Part I Create a Java program that inputs a grade from the user. The grade input from the user will be an integer. Once the input is stored, use an if-else-if block of code to determine the letter grade of the inputted integer grade. Do not use a bunch of if statements by themselves to solve this problem. You will print an error message for inputs greater than 100 and for inputs less than 0. Both errors must be handled...

  • Write a program that asks the user for a student name and asks for grades until...

    Write a program that asks the user for a student name and asks for grades until the user enters a non-number input, it should then ask if the user wants to enter another student, and keep doing the process until the user stops adding students. The student’s must be stored in a dictionary with their names as the keys and grades in a list. The program should then iterate over the dictionary elements producing the min, max, and mean of...

  • In a file called First SecondNext.java, write a program that: • Asks the user to enter...

    In a file called First SecondNext.java, write a program that: • Asks the user to enter a string that contains at least five letters. It is OK if your program crashes when the user enters a string with length less than 5. • Stores that string in a variable called s. • Creates a variable called "first", and sets it equal to the first letter of s. • Creates a variable called "second", and sets it equal to the second...

  • Write a program that asks the user to enter five test scores. The program should display...

    Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Design the following functions in the program: calcAverage—This function should accept five test scores as arguments and return the average of the scores. determineGrade—This function should accept a test score as an argument and return a letter grade for the score (as a String), based on the following grading scale: Score Letter Grade...

  • Write a java program that asks the user to enter 2 integers, obtains them from the...

    Write a java program that asks the user to enter 2 integers, obtains them from the user, determines if they are even or odd numbers and prints their sum, product, difference, and quotient (Division).

  • Write a program that asks the user to input 5 integers in an Array named "gradearray.”...

    Write a program that asks the user to input 5 integers in an Array named "gradearray.” then passes gradearray in a function to find how many passing grades exist. (passing grades are between 60 and 100) Input elements for the gradearray : 67 43 90 100 75 There are 4 passing grades There are 1 failing grades

  • Write a python program that repeatedly asks the user to input a pair of integers. The...

    Write a python program that repeatedly asks the user to input a pair of integers. The program should record the largest number of each pair into a list. The program should keep asking the user to input pairs of numbers until the user enters -1 for the first number. At this point the program should print the list on a single line, with each value separated by a space and then stop. Example of expected behaviour: Please enter first number:...

  • Write a C# program that asks the user to start a counter from 0-6. Then it...

    Write a C# program that asks the user to start a counter from 0-6. Then it ask the user to increment the counter from a given value by the user. After its incremented, display that value. For example: Counter is from 0-6 User enters counter start of 1 User enters a count of 10 Count stops on 4 of the counter

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT