Question

In: Computer Science

USING C++ PLEASE Write a program named Lab11C that calculates the average of a group of...

USING C++ PLEASE

Write a program named Lab11C that calculates the average of a group of test scores where the lowest score is dropped. It should use the following functions

a) void getScores should have 4 double reference parameters (one for each test score)
getScores should do the following:

- read 4 test scores from the text file Lab11C.txt (Important: declare your ifstream infile and open the file inside this function, not in the main function)
- store them in the reference parameters

b) void calcAverage (4 double parameters) should do the following:

- call findLowest passing the test scores as parameters

- total the 4 scores and subtract the result returned by findLowest

- this will leave you with the total of 3 test scores, so divide the total by 3

- print the average with a label

c) double findLowest (so it has 4 double parameters) should find and return the lowest of the 4 scores passed to it.

​​​​​​​​​​​​​​d) In the main function

- call getScores sending 4 double variables as parameters

- call calcAverage sending those 4 double variables

Note about reference parameters: remember that with reference parameters, you will use the & in the top line of the function itself, but you will not use the & in the call to the function in main.

Solutions

Expert Solution

Main Code :

#include<iostream>
#include<fstream>
using namespace std;
void getScores(double &a,double &b,double &c,double &d)
{
ifstream f;
f.open("Lab11C.txt");
if(!f)
cout<<"Unable to open the file";
else
{
f>>a;
f>>b;
f>>c;
f>>d;
}
f.close();
}
double findLowest(double a,double b,double c,double d)
{
if((a<b)&&(a<c)&&(a<d))
return a;
else if((b<c)&&(b<d))
return b;
else if(c<d)
return c;
else
return d;
}
void calcAverage(double a,double b,double c,double d)
{
double low=findLowest(a,b,c,d);
double tot=a+b+c+d;
tot=(tot-low)/3;
cout<<"Average = "<<tot;
}
int main()
{
double a,b,c,d;
getScores(a,b,c,d);
calcAverage(a,b,c,d);
}

File : Lab11C.txt

Output :


Related Solutions

Write a C program that calculates the average grade for a specified number of students from...
Write a C program that calculates the average grade for a specified number of students from each student's test1 and test2 grades. The program must first ask the user how many students there are. Then, for each student, the program will ask the user for the test1 grade (grade #1) and test2 grade (grade #2). The program should be able to handle up to 100 students, each with 2 grades (test1 and test2). Use a two-dimensional float array to store...
Write a program named MakeChange that calculates and displays the conversion of an entered number of...
Write a program named MakeChange that calculates and displays the conversion of an entered number of dollars into currency denominations—twenties, tens, fives, and ones. For example, if 113 dollars is entered, the output would be twenties: 5 tens: 1 fives: 0 ones: 3. Answer in C# (P.S i'm posting the incomplete code that i have so far below.) using System; using static System.Console; class MakeChange { static void Main() { int twenties, tens, fives, ones; WriteLine("Enter the number of dollars:");...
Question 2: Write a java program that calculates the weighted average of three grades using the...
Question 2: Write a java program that calculates the weighted average of three grades using the method with header public static double CalculateWeightedAverage (double grade1, double grade2, double grade3), such that: [4 Marks] Weighted average = grade1 * 0.5 + grade2 * 0.25 + grade3 * 0.25 The program in the main method will: o ask the user to enter the three grades o and then call the method that will calculate the weighted average o and finally display the...
using C# Write a program named RectangleArea tocalculate the area of a rectangle with a...
using C# Write a program named RectangleArea to calculate the area of a rectangle with a length of 15.8 and a width of 7.9. The program should have two classes, one is theRectangleArea holding the Main(), and the other one is Rectangle. The Rectangleclass has three members: a property of length, a property of width, and a method with a name of CalArea() to calculate the area. You can invoke the auto-provided constructor or write a self-defined constructor to initialize...
Please use Phyton to write a program: Write a program that calculates and displays the total...
Please use Phyton to write a program: Write a program that calculates and displays the total bill at a restaurant for a couple that is dining. The program should collect from the couple, cost of each meal, and the percentage of the final cost that they would like to tip. The sales tax in the state where the restaurant exists is 7.5%. Display to the user, line by line: Total Cost of Both Meals Sales Tax in dollars Tip in...
Your task is to write a program in C or C++ that calculates the total amount...
Your task is to write a program in C or C++ that calculates the total amount of money a person has made over the last year. Your program will prompt the user for dollar amounts showing how much the user has made per job. Some users will have had more than one job, make sure your program allows for this. The program will print out the total made (all jobs) and will print out the federal and state taxes based...
Write a C++ program that calculates mileage reimbursement for a salesperson at a rate of $...
Write a C++ program that calculates mileage reimbursement for a salesperson at a rate of $ 0.35 per mile. Your program should interact with the user in this manner: MILEAGE REIMBURSEMENT CALCULATOR Enter beginning odometer reading: 13505.2 Enter ending odometer reading     : 13810.6 You traveled 305.40 miles. At $ 0.35 per mile, your reimbursement is $ 106.89. The values in red color are inputs for the program. The values in blue color are results of expressions.
***Please answer the question using the JAVA programming language. Write a program that calculates mileage reimbursement...
***Please answer the question using the JAVA programming language. Write a program that calculates mileage reimbursement for a salesperson at a rate of $0.35 per mile. Your program should interact (ask the user to enter the data) with the user in this manner: MILEAGE REIMBURSEMENT CALCULATOR Enter beginning odometer reading > 13505.2 Enter ending odometer reading > 13810.6 You traveled 305.4 miles. At $0.35 per mile, your reimbursement is $106.89. ** Extra credit 6 points: Format the answer (2 points),...
Write a C program that calculates a student grade in the C Programming Class. Ask the...
Write a C program that calculates a student grade in the C Programming Class. Ask the user to enter the grades for each one of the assignments completed in class: Quiz #1 - 25 points Quiz #2 - 50 points Quiz #3 - 30 points Project #1 - 100 points Project #2 - 100 points Final Test - 100 points The total of the quizzes count for a 30% of the total grade, the total of the projects counts for...
(using C in a Linux environment and the POSIX pthreads library) Write a program named Sort.c...
(using C in a Linux environment and the POSIX pthreads library) Write a program named Sort.c that accepts a list of numbers from the user. There are two threads: Main thread waits for the numbers to be entered by the user and for the second thread to finish sorting. It then asks user whether there are more lists or not. It will do this until the user indicates there are no more lists to be entered, at which point it...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT