Question

In: Computer Science

Complete the following assignment in C programming language. 1. Declare the following float variables: -Maximum exam...

Complete the following assignment in C programming language.

1. Declare the following float variables:

-Maximum exam score, user's exam score, and percentage.

2. Ask the user to input data into your variables, such as:

-"What is the max score of your exam:"

-"What was your score:"

3. Use if statements to validate user inputs. For example, score received should not be more than maximum possible score.

-Display an error message when the user enters invalid data.

-You can restart the program if use enters invalid input by pressing the RESET button on the processor board.

4. Build your Software logic to calculate the percentage and the letter grade.

-Hint: Store your letter grade to a char variable.

-Hint: Use if and else if statements. Scan from A to D leaving F to else statement.

5. Print out summary for the user:

-If the user's grade is either B, C, or D, print-out how many percent points the user is away from the next letter grade.

-Hint: (Score % 10) will tell you the remainder. If grade is B, C or D, calculate the remainder and subtract from 10.

-Example print-out:

-"You scored a B, and you were 3 percent away from the next letter grade."

Solutions

Expert Solution

Thanks for the question.


Below is the code you will be needing Let me know if you have any doubts or if you need anything to change.


Thank You !!


===========================================================================

#include<stdio.h>

int main(){
  
   float max_exam_score;
   float user_exam_score;
   float percentage;
  
   printf("What is the max score of your exam: ");
   scanf("%f",&max_exam_score);
   printf("What was your score: ");
   scanf("%f",&user_exam_score);
  
   if(user_exam_score<=max_exam_score && user_exam_score>=0 && max_exam_score>=0){
      
       percentage = 100.0*user_exam_score/max_exam_score;
       if (percentage>=90){
           printf("You scored a A\n");
       }else if(percentage>=80){
          
           int away = 10 - int(percentage)%10;
           printf("You score a B, and you were %d percent away from the next letter grade.\n",away);
       }
       else if (percentage>=70){
           int away = 10 - int(percentage)%10;
           printf("You score a C, and you were %d percent away from the next letter grade.\n",away);
       }else if (percentage>=60){
           int away = 10 - int(percentage)%10;
           printf("You score a D, and you were %d percent away from the next letter grade.\n",away);
       }else{
           printf("You scored a F.\n");
       }
      
   }else{
       printf("ERROR: Invalid Data provided.\n");
      
   }
}

======================================================================


Related Solutions

Complete the following assignment in C programming language. Get the user’s first name and store it...
Complete the following assignment in C programming language. Get the user’s first name and store it to a char array Declare a character array to hold at least 20 characters. Ask for the user’s first name and store the name into your char array. Hint: Use %s for scanf. %s will only scan one word and cannot scan a name with spaces. Get 3 exam scores from the user: Declare an array of 3 integers Assume the scores are out...
Complete the following assignment in C programming language. Get the user’s first name and store it...
Complete the following assignment in C programming language. Get the user’s first name and store it to a char array Declare a character array to hold at least 20 characters. Ask for the user’s first name and store the name into your char array. Hint: Use %s for scanf. %s will only scan one word and cannot scan a name with spaces. Get 3 exam scores from the user: Declare an array of 3 integers Assume the scores are out...
C PROGRAMMING 1. Write a C Language inline function that computes the cube of float X,...
C PROGRAMMING 1. Write a C Language inline function that computes the cube of float X, if X is greater than 1 and X is less than 100. Put the inline function in a main program that reads X from the keyboard, calls the function, and then outputs the result. 2. Show an empty statement and detail what it does? 3. A collection of predefined functions is called a Database                    C) Subroutine                       E) None of these Library                       D) Directive 4....
Assignment #1: Sorting with Binary Search Tree (IN C LANGUAGE) Through this programming assignment, the students...
Assignment #1: Sorting with Binary Search Tree (IN C LANGUAGE) Through this programming assignment, the students will learn to do the following: 1. Know how to process command line arguments. 2. Perform basic file I/O. 3. Use structs, pointers, and strings. 4. Use dynamic memory. This assignment asks you to sort the lines of an input file (or from standard input) and print the sorted lines to an output file (or standard output). Your program, called bstsort (binary search tree...
Part II: Programming Questions NOTE: CODING LANGUAGE IS C# PQ1. How would you declare the following...
Part II: Programming Questions NOTE: CODING LANGUAGE IS C# PQ1. How would you declare the following scalar and non-scalar (vector) variables? counter, an integer sum, a decimal number average, a decimal number grades, an array of 32 decimal numbers PQ2. How would you initialize the array above with numbers between 0.0 and 4.0 representing the grades of all courses a senior has received in the four years of college? Instead of initializing the array above, how would you, in a...
In C++ Programming Language: 1a. Declare a class, namely ReverseUniverse, that contains three public member functions....
In C++ Programming Language: 1a. Declare a class, namely ReverseUniverse, that contains three public member functions. Please see Q2 and Q3 for the name of the second and third function. (5 points) Write a function string reverseString that reverses a string (first member function). It takes a string parameter and returns its reversed version. (10 points) 1b. In the class ReverseUniverse in Q1. Write a function vector reverseVector that reverses a vector (second member function). It takes a double vector...
Complete the following exercises using C programming language. Take screenshots of the code and its output...
Complete the following exercises using C programming language. Take screenshots of the code and its output where specified and paste them into in a well-labeled Word document for submission. Scenario Assume you are the CIO of an organization with three different IT department locations with separate costs. You want a program to perform simple IT expenditure calculations. Your IT expenditure target is $35,000 per site. Site expenditures: Site 1 – $35,000. Site 2 – $37,500. Site 3 – $42,500. Exercise...
C programming Assignment 1. Read two integers into two variables, A and B. Print them on...
C programming Assignment 1. Read two integers into two variables, A and B. Print them on terminals. Write functions to Swap them (1) using a temporary variable and (2) without using a temporary variable. 2. Read 10 integers into an array. Sort the array. Then print the sorted array. 3. Read 16 integers into an array. Use merge sort algorithm to sort it. 4. Read 16 integers into an array. Sort it using merge sort algorithm. Then read a number...
c++ Programming Assignment 1: Game of Life The objective of this programming assignment is to design...
c++ Programming Assignment 1: Game of Life The objective of this programming assignment is to design and implement what is known as the “Game of Life”, conceptualized by the British mathematician John Horton Conway in 1970 to simulate the evolution patterns in a population of living organisms.   The game board is seeded with an initial population pattern, and then evolves based on the set of rules defining when a cell dies or is born into life. A cell’s life cycle...
Programming Language: C++ Overview For this assignment, write a program that will simulate a single game...
Programming Language: C++ Overview For this assignment, write a program that will simulate a single game of Craps. Craps is a game of chance where a player (the shooter) will roll 2 six-sided dice. The sum of the dice will determine whether the player (and anyone that has placed a bet) wins immediately, loses immediately, or if the game continues. If the sum of the first roll of the dice is equal to 7 or 11, the player wins immediately....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT