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...
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....
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...
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....
In C/C++ programming language, write down the lines of codes (and figure) to show- a) assignment-by-sharing...
In C/C++ programming language, write down the lines of codes (and figure) to show- a) assignment-by-sharing b) dangling reference
Programming Language Concept assignment: 1. Design abstract data type for matrices with integer elements in C++...
Programming Language Concept assignment: 1. Design abstract data type for matrices with integer elements in C++ language, including operations for matrix addition, subtraction, and multiplication! 2. Design abstract queue data types for float elements in C++ language, including operations for enqueue, dequeue, and empty. The dequeue operation removes the element and returns its value! 3. Set semaphores in Ada and use them to provide co-operation and synchronization of competitions in shared buffer instances!
JAVASCRIPT: /* Assignment 03: Complete this javascript */ // 1) Declare a variable named myValue //...
JAVASCRIPT: /* Assignment 03: Complete this javascript */ // 1) Declare a variable named myValue // Assign myValue the value of "Hello, how's it going?" // Print the value of myValue to the console // 2) Use the charAt() method to display the letter t // from the variable myValue in the console // 3) Use the indexOf() method to display the position of "going" // from the variable myValue in the console // 4) Use the slice() method to...
Hi, I am working on an assignment in C-Programming language dealing with LInked lists, in the...
Hi, I am working on an assignment in C-Programming language dealing with LInked lists, in the code there is instructions on where to write the code. I do not know how to write Linked Lists. Has to be in the C-language, Any help is greatly appreciated   //agelink.c //maintains list of agents //uses linked list #include <stdio.h> #include <stdlib.h> #define TRUE 1 void listall(void); void newname(void); void delink(void); void memexit(void); void wfile(void); /********************************************************************* this is the structure to hold a agent...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT