Question

This program should be written in C Thoroughly following the Code Conventions, write an efficient program,...

This program should be written in C

  1. Thoroughly following the Code Conventions, write an efficient program, which ask the user for their numeric grade, and determines and displays the equivalent letter grade, based on the following information:
    • Use appropriate data types and initialize the variables correctly
    • Use the following grading scale:
      • A: 90 - 100
      • B: 80 - < 90
      • C: 70 - < 80
      • D: 60 - < 70
      • F: 0 - < 60
    • If the input is invalid, e.g., grade > MAX_A, an appropriate and specific error message should be displayed starting with a blank line and tab, and following with a blank line; in other words, make the error message stand out from the rest of the information displayed to the screen, for example, where the ellipses below are what is displayed before and after the error message, and the error message is offset and surrounded by white space:
      • ...
        
            Error: The numeric grade must be less than or equal to 100.
        
        ...
    • Thoroughly test your program by using appropriate test cases based on the values in the grading scale, e.g., -1, 0, 59, 60, 69, 70, 79, 80, 89, 90, 100, 101
    • Do NOT use stacked if or if-else constructs, i.e., this problem, like most, should use nested if-else constructs, which usually are more efficient, i.e., stacked if or if-else constructs are usually inefficient
    • Make sure your output is written professionally, e.g., sentences begin with a capital letter and end with punctuation, words are spelled correctly, there is a space after a colon, there is a blank line between getting the input and displaying the results, which should consist of only one statement, e.g., Your letter grade is ..., etc.
    • Only use the concepts covered through Module 5; see the module overviews
  2. Once you have completed and thoroughly tested your program, unless told otherwise during class, complete the following steps:
    1. Copy and paste your code from your IDE into a Microsoft Word document. Do NOT reformat your code after pasting it.
    2. Save and close the Word document.
    3. Attach the Word document to this assignment.
    4. Submit it.
    5. Verify the document you just submitted is the correct one.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer to the above question as follows-

we have to use nested if-else structure.

A nested if else means an if statement within another if statement.

These are considered to be faster than if-else-if ladder.

Required code for C language is as follows


#include <stdio.h>

int main() {
  
   int n; // declaring variable n to store numeric grade value
   char grade; // declaring character grade to store letter grade value
  
  
   //Input
   printf("Enter your numeric grade.\n");
   scanf("%d",&n); // takng input from the user
  
  
   //Evaluation
   if( n>100 || n<0 ){ // check if invalid numeric grade
   printf("\n\n\n"); // print in desired format
   printf(" Error: The numeric grade must be less than or equal to 100.");
   printf("\n\n\n");
   exit(0); // exit from the program
   }
   else{
   if ( n >= 90)
{
grade = 'A'; // assign grade A
}
else
{
if (n >= 80 && n <= 89)
{
grade = 'B'; // assign grade B
}
else
{
if (n >= 70 && n <= 79)
{
grade = 'C'; // assign grade C
}
else
{
if (n >= 60 && n <= 69)
{
grade = 'D'; // assign grade D
}
else
{
grade = 'F'; // assign grade F
}
}
}
}
   }
     
     
   //Output   
   printf("\nYour letter grade is %c\n",grade); //Display the letter grade
   return 0;
}

Screenshot of the executed code is as follows-

Screenshot of the tested output are-

Please COMMENT if you have any queries regarding the solution.

Please THUMBS UP and UPVOTE if you find the answer helpful and satisfactory.

Thank You !!!

Add a comment
Know the answer?
Add Answer to:
This program should be written in C Thoroughly following the Code Conventions, write an efficient program,...
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
  • Write a grading program for the following grading policies:- a. There are two quizzes, each graded...

    Write a grading program for the following grading policies:- a. There are two quizzes, each graded on the basis of 10 points. b. There is one midterm exam and one final exam, each graded on the basis of 100 points. c. The final exam counts for 50 percent of the grade, the midterm counts for 25 percent and the two quizzes together count for a total of 25 percent. Grading system is as follows:- >90 A >=80 and <90 B...

  • Java Programming Language Edit and modify from the given code Perform the exact same logic, except...

    Java Programming Language Edit and modify from the given code Perform the exact same logic, except . . . The numeric ranges and corresponding letter grade will be stored in a file. Need error checking for: Being able to open the text file. The data makes sense: 1 text line of data would be 100 = A. Read in all of the numeric grades and letter grades and stored them into an array or arraylist. Then do the same logic....

  • Write a C++ program that will provide a user with a grade range if they enter...

    Write a C++ program that will provide a user with a grade range if they enter a letter grade. Your program should contain one function. Your function will accept one argument of type char and will not return anything (the return type will be void), but rather print statements to the console. Your main function will contain code to prompt the user to enter a letter grade. It will pass the letter grade entered by the user to your function....

  • In C Langage Write a grading program for a class with the following grading policies:- a. There are two quizzes, each gr...

    In C Langage Write a grading program for a class with the following grading policies:- a. There are two quizzes, each graded on the basis of 10 points. b. There is one midterm exam and one final exam, each graded on the basis of 100 points. c. The final exam counts for 50 percent of the grade, the midterm counts for 25 percent and the two quizzes together count for a total of 25 percent. Grading system is as follows:-...

  • using if/switch statements (C++) Write a grading program for a class with the following grading policies:...

    using if/switch statements (C++) Write a grading program for a class with the following grading policies: There are two quizzes, each graded on the basis of 10 points There is one midterm exam and one final exam, each graded on the basis of 100 points The final exam counts for 50% of the grade, the midterm counts for 25% and the two quizzes together count for a total of 25%. (Do not forget to normalize the quiz scores. They should...

  • Test Scores and Grade Write a program that has variables to hold three test scores. The...

    Test Scores and Grade Write a program that has variables to hold three test scores. The program should ask the user to enter three test scores and then assign the values entered to the variables. The program should display the average of the test scores and the letter grade that is assigned for the test score average. Use the grading scheme in the following table: Test Score Average Letter Grade 90–100 A 80–89 B 70–79 C 60–69 D Below 60...

  • Java Program: In this project, you will write a program called GradeCalculator that will calculate the...

    Java Program: In this project, you will write a program called GradeCalculator that will calculate the grading statistics of a desired number of students. Your program should start out by prompting the user to enter the number of students in the classroom and the number of exam scores. Your program then prompts for each student’s name and the scores for each exam. The exam scores should be entered as a sequence of numbers separated by blank space. Your program will...

  • 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...

  • Create a MIPS program that does the following: 4. Determine the letter grade a. Use the...

    Create a MIPS program that does the following: 4. Determine the letter grade a. Use the floating point calculated average to determine the letter grade. You will need to research the instructions to use to do comparisons with floating point numbers. (see Course Resources) b. Use the following chart: 90 - 100 80 - 89 70 - 79 ............. 60 - 69.............. <60 ..................... ............... 5. Display a message and the letter grade. 6. Your output should look similar to...

  • Write a Java program that reads a file until the end of the file is encountered....

    Write a Java program that reads a file until the end of the file is encountered. The file consists of an unknown number of students' last names and their corresponding test scores. The scores should be integer values and be within the range of 0 to 100. The first line of the file is the number of tests taken by each student. You may assume the data on the file is valid. The program should display the student's name, average...

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
ADVERTISEMENT