Question

In: Computer Science

write a program in c++ that asks the user to enter their 5 test scores and...

write a program in c++ that asks the user to enter their 5 test scores and calculates the most appropriate mean. Have the results print to a text file and expected results to print to screen.

Solutions

Expert Solution

Code:

#include<iostream>
#include<fstream>
using namespace std;
int main()
{
   int marks,i;
   double total;/*Declaring variables*/
   ofstream File("mean.txt");/*file*/
   cout<<"Enter the marks of 5 tests: "<<endl;
   File<<"Test Scores\n";/*Writing into the file*/
   for(i=1;i<=5;i++)
   {
       cin>>marks;/*Reading marks from the user user*/
       total+=marks;/*Calculating the total*/
       File<<marks<<"\n";/*Writing marks into the file*/
   }
   cout<<"Mean:"<<total/5;/*Printing mean on to the screen*/
   File<<"Mean:"<<total/5;/*Writing mean into the file*/
}

Output:

Output in the file:

Indentation:


Related Solutions

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. Write the following methods in the program: calcAverage: This method should accept five test scores as arguments and return the average of the scores. determineGrade: This method should accept a test score as an argument and return a letter grade for the score, based on the following grading scale: Score Letter Grade 90-100...
Instructions Write a Java program that asks the user t enter five test scores. The program...
Instructions Write a Java program that asks the user t enter five test scores. The program should display a letter grade for each score and the average test score. Write the following methods in the program: * calcAverage -- This method should accept five test scores as arguments and return the average of the scores. * determineGrade -- This method should accept a test score as an argument and return a letter grade for the score, based on the following...
Write a C++ program that asks the user to enter the monthly costs for the following...
Write a C++ program that asks the user to enter the monthly costs for the following expenses incurred from operating your automobile: loan payment, insurance, gas, oil, tires, and maintenance. The program should then display the total monthly cost of these expenses, and a projected total annual cost of these expenses. Label each cost. The labels should be left aligned and have a column width of 30 characters. The cost should be aligned right and displayed with two decimal places...
Write a C program that loops and asks a user to enter a an alphanumeric phone...
Write a C program that loops and asks a user to enter a an alphanumeric phone number and converts it to a numeric one. No +1 at the beginning. You can put all code in one quiz1.c file or put all functions except main in phone.c and phone.h and include it in quiz1.c Submit your *.c and .h files or zipped project */ #pragma warning (disable: 4996) //windows #include <stdio.h> #include <string.h> #include <stdbool.h> #include <ctype.h> enum { MaxLine =...
C++ write a program that asks the user to enter the hours and rate then calculate...
C++ write a program that asks the user to enter the hours and rate then calculate the gross pay for an employee, the program should test if the hours are regular (40), any hour more than 40 should be paid with the overtime rate: 1.5*rate. The program should ask repeatedly the user if he/she wants to continue: y or n, if the user types y, then the program should ask for the hours and rate for another employee then display...
In the space provided below write a C++ program that asks the user to enter their...
In the space provided below write a C++ program that asks the user to enter their quarterly earnings for the past two years stores the data in a 2-dimensional array. The program then computes both the annual earnings as well as the total earning and prints the results along with the 2-dimensional array on screen as well as onto a file.
1/Write a C program that asks the user to enter 5 nums and adds each number...
1/Write a C program that asks the user to enter 5 nums and adds each number to a total. The program should then display the total. To add to the total, the program must call the function void sum(int value, int *ptotal) passing the value the user entered and the address of the total (a local variable in main). The function should add the value to the total. Note that the function is void and does not return anything. Don't...
Write a javascript program that asks the user to enter up to 10 golf scores, which...
Write a javascript program that asks the user to enter up to 10 golf scores, which are to be stored in an array. You should provide a means for the user to terminate input prior to entering 10 scores. The program should display all the scores on one line and report the average score. Handle input, display, and the average calculation with three separate array processing functions.
in C++, Write a program that asks the user to enter 6 numbers. Use an array...
in C++, Write a program that asks the user to enter 6 numbers. Use an array to store these numbers. Your program should then count the number of odd numbers, the number of even numbers, the negative, and positive numbers. At the end, your program should display all of these counts. Remember that 0 is neither negative or positive, so if a zero is entered it should not be counted as positive or negative. However, 0 is an even number....
Write a C program that asks the user to enter any two integernumbers, and each...
Write a C program that asks the user to enter any two integer numbers, and each number consists of four-digits. Your program should check whether the numbers are four digits or not and in case they are not a four digit number, the program should print a message and exit, otherwise it should do the following:Print a menu as follows:Select what you want to do with the number 1-3:1- Print Greatest Common Divisor (GCD) of the two numbers.2- Print sum...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT