Question

In: Computer Science

C++ Programming in Linux The program will read the five grades from the keyboard, calculate the...

C++ Programming in Linux

The program will read the five grades from the keyboard, calculate the median, and then then display it. In addition, the program will calculate the average of the five grades and display it as well. Your program should ask the user to input the five grades and then return the median and average. Continue until the user quits.

Solutions

Expert Solution

#include <iostream>

using namespace std;
int main(){
   double arr[5];
   double avg;
   int ch=1;
   while(ch){
       avg=0;
       cout<<"Enter 5 grades: ";
       for(int i=0;i<5;i++){
           cin>>arr[i];
           avg=avg+arr[i];
       }
       cout<<"Average : "<<avg/5<<endl;
       cout<<"Median : "<<arr[2]<<endl;
       cout<<"Press 1 to continue 0 to quit: ";
       cin>>ch;
   }

}

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me


Related Solutions

Write a C++ program to read characters from the keyboard until a '#' character is read....
Write a C++ program to read characters from the keyboard until a '#' character is read. Then the program will find and print the number of uppercase letters read from the keyboard.
Write a C++ program to read in a list of 10 integers from the keyboard. Place...
Write a C++ program to read in a list of 10 integers from the keyboard. Place the even numbers into an array called even, the odd numbers into an array called odd, and the negative numbers into an array called negative. Keep track of the number of values read into each array. Print all three arrays after all the numbers have been read. Print only the valid elements (elements that have been assigned a value). a. Use main( ) as...
Write a C program that allows: Three integer values to be entered (read) from the keyboard,...
Write a C program that allows: Three integer values to be entered (read) from the keyboard, Display the sum of the three values on the computer screen as follows: The integers that you have entered are: a b c The sum of a , b & c is ______ Thank you! C Code: Output screen:
Write a program in C++ to read 10 numbers from keyboard and find their sum, average,...
Write a program in C++ to read 10 numbers from keyboard and find their sum, average, maximum and minimum
( C programming ) Write a program that will process an arbitrary number of grades each...
( C programming ) Write a program that will process an arbitrary number of grades each time the program is run. (Hints: sentinel-controlled iteration.) If grade >= 90, its corresponding letter grade is A. If 80 <= grade < 90, its corresponding letter grade is B. If 70 <= grade < 80, its corresponding letter grade is C. If 60 <= grade < 70, its corresponding letter grade is D. If grade < 60, its corresponding letter grade is F....
Write a program in python to read from a file the names and grades of a...
Write a program in python to read from a file the names and grades of a class of students to calculate the class average, the maximum, and the minimum grades. The program should then write the names and grades on a new file identifying the students who passed and the students who failed. The program should consist of the following functions: a) Develop a getGrades() function that reads data from a file and stores it and returns it as a...
C++ programming question Write a program that will read input from a text file called "theNumbers.txt"...
C++ programming question Write a program that will read input from a text file called "theNumbers.txt" (you will have to provide your own when debugging). The text file that is to be opened is formatted a certain way, namely, there is always one integer, one character (representing an operation), another integer, and then a new line character, with spaces between each item. A sample text file is provided below. theNumbers.txt 144 + 26 3 * 18 88 / 4 22...
Write a python program to read from a file the names and grades of a class...
Write a python program to read from a file the names and grades of a class of students to calculate the class average, the maximum, and the minimum grades. The program should then write the names and grades on a new file identifying the students who passed and the students who failed. The program should consist of the following functions: a) Develop a gradesInput() function that reads data from a file and stores it and returns it as a dictionary....
Write a pyhton program to read from a file the names and grades of a class...
Write a pyhton program to read from a file the names and grades of a class of students, to calculate the class average, the maximum, and the minimum grades. The program should then write the names and grades on a new file identifying the students who passed and the students who failed. The program should consist of the following functions: a) Develop a dataInput() function that reads data from a file and stores it and returns it as a dictionary....
Write a java program to read a string from the keyboard, and count number of digits,...
Write a java program to read a string from the keyboard, and count number of digits, letters, and whitespaces on the entered string. You should name this project as Lab5B. This program asks user to enter string which contains following characters: letters or digits, or whitespaces. The length of the string should be more than 8. You should use nextLine() method to read string from keyboard. You need to extract each character, and check whether the character is a letter...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT