Question

In: Computer Science

In C ++, Design and implement a program that reads from the user four integer values...

In C ++, Design and implement a program that reads from the user four integer values between 0 and 100, representing grades. The program then, on separate lines, prints out the entered grades followed by the highest grade, lowest grade, and averages of all four grades. Format the outputs following the sample runs below.

Sample run 1:

You entered:    95, 80, 100, 70

Highest grade: 100

Lowest grade:   70

Average grade: 86.25

Solutions

Expert Solution

#include <iostream>

using namespace std;

int main()
{
   int a,b,c,d,max,min,sum;
   cin>>a;
   cin>>b;
   cin>>c;
   cin>>d;
   cout<<"You entered:    ";
   cout<<a<<", "<<b<<", "<<c<<", "<<d<<endl;
   
   max = a;
   min = a;
   
   if(max < b){
      max = b;
   }
   if(max < c){
      max = c;
   }
   if(max < d){
      max = d;
   }
   
   if(min > b){
      min = b;
   }
   if(min > c){
      min = c;
   }
   if(min > d){
      min = d;
   }
   
   sum = a+b+c+d;
   
   cout<<"Highest grade: "<<max<<endl;
   cout<<"Lowest grade: "<<min<<endl;
   cout<<"Average grade: "<<(sum/4.0)<<endl;
    return 0;
}


Related Solutions

In C++ Design and implement a program (name it ProcessGrades) that reads from the user four...
In C++ Design and implement a program (name it ProcessGrades) that reads from the user four integer values between 0 and 100, representing grades. The program then, on separate lines, prints out the entered grades followed by the highest grade, lowest grade, and averages of all four grades. Format the outputs following the sample runs below.
Using C# Design and implement a program (name it ProcessGrades) that reads from the user four...
Using C# Design and implement a program (name it ProcessGrades) that reads from the user four integer values between 0 and 100, representing grades. The program then, on separate lines, prints out the entered grades followed by the highest grade, lowest grade, and averages of all four grades. Format the outputs following the sample runs below. Sample run 1: You entered:   95, 80, 100, 70 Highest grade:100 Lowest grade:  70 Average grade:86.25
Design and implement a program that reads a series of 10 integers from the user and...
Design and implement a program that reads a series of 10 integers from the user and prints their average. Read each input value as a string, and then attempt to convert it to an integer using the Integer.parseInt method. If this process throws a NumberFormatException (meaning that the input is not a valid number), print an appropriate error message and prompt for the number again. Continue reading values until 10 valid integers have been entered.
1. Design and implement a program that reads a series of integers from the user and...
1. Design and implement a program that reads a series of integers from the user and continually prints their average after every reading. The input stops when the user enters “stop” as the input value. Read each input value as a string, then check if it is “stop” or not. If the string is not “stop”, then, attempt to convert it to an integer using the Integer.parseInt method. If this process throws a NumberFormatException, meaning that the input is not...
Design and implement a program that reads a series of 10 integers from the user and...
Design and implement a program that reads a series of 10 integers from the user and prints their average. Read each input value as a string, then attempt to convert it to an integer using the Integer.parseInt method. If this process throws a NumberFormatException (meaning that the input is not a valid integer), display an appropriate error message and prompt for the number again. Continue reading values until 10 valid integers have been entered.
IN C++ Write a program that reads in int values from the user until they enter...
IN C++ Write a program that reads in int values from the user until they enter a negative number like -1. Once the user has finished entering numbers, print out the highest value they’ve entered, the lowest value they’ve entered, and the total number of numbers they’ve entered. The negative number they entered should not be taken as one of the values entered.
Write a Java program (name it LargestOccurenceCount) that reads from the user positive non-zero integer values,...
Write a Java program (name it LargestOccurenceCount) that reads from the user positive non-zero integer values, finds the largest value, and counts it occurrences. Assume that the input ends with number 0 (as sentinel value to stop the sentinel loop). The program should ignore any negative input and should continue to run. Hint: to remember/save entered (good) values, you can concatenate them into a string (separated by spaces) that you can output later on. Sample runs showing input prompts and...
C++ program that reads a positive integer number from a user and displays all binary numbers...
C++ program that reads a positive integer number from a user and displays all binary numbers from 0 to the number. For the program, you can assume that the input number is a number between 0 and 100. Sample Run 1: Assume that the user typed the following number. 5 This is the correct output of your program. 000 001 010 011 100 101 Sample Run 2: Assume that the user typed the following number. 0 This is the correct...
in.java Write a program that reads an integer from the user and prints a rectangle of...
in.java Write a program that reads an integer from the user and prints a rectangle of starts of width 5 3 and height N. Sample run 1: Enter N: 5 *** *** *** *** *** Bye Sample run 2: Enter N: 8 *** *** *** *** *** *** *** *** Bye Sample run 3: Enter N: 2 *** *** Bye Sample run 4: Enter N: -2 Bye
programing language JAVA: Design and implement an application that reads a sentence from the user, then...
programing language JAVA: Design and implement an application that reads a sentence from the user, then counts all the vowels(a, e, i, o, u) in the entire sentence, and prints the number of vowels in the sentence. vowels may be upercase
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT