Create a program that contains 4 methods/functions... main(), getTestScores(), c
ID: 3679194 • Letter: C
Question
Create a program that contains 4 methods/functions... main(), getTestScores(), calcAverage(), and displayAverage()- The main() method should call the getTestScores() method to get and return each of 3 test scores. The main function should then call the calcAverage() method to calculate and return the average of the three test scores. The main() method should then call the displayAverage() method to display the average of the test scores. The final date/time to submit this assignment is Friday, March 18th at midnight. Create a program that contains 4 methods/functions... main(), getHoursWorked(), getPayRate(), and calcGross()- The main() method should call each method/function and then display the gross pay. Note - do not worry about overtime pay....assume overtime is paid at the same Pay Rate. The final date/time to submit this assignment is Friday, March 18th at midnight. Write a program that allows the user to enter a temperature and whether the temperature is stated in Celsius or Fahrenheit...or whether you want to convert Celcius to Fahrenheit or Fahrenheit to Celcius. If the given temperature is Celsius...mainO should call a method called convertToFahrenheit to convert and return the new Fahrenheit equivalent temperature. If the given temperature is fahrenheit...mainO should call a method called convertToCelcius to convert and return the new Celsius equivalent temperature. Either way display the converted temperature and some output comments with it. Be sure to check your formulas to make sure they work. Have the user enter a number such as 1 to convert Celcius to Fahrenheit and 2 to convert Fahrenheit to Celcius. The final date/time to submit this assignment is Friday, March 18th at midnight.Explanation / Answer
A) Average Test Score
#include <iostream>
#include <iomanip>
using namespace std;
double calcAverage(double Test_Score1 = 0.0, double Test_Score2 = 0.0, double Test_Score3 = 0.0);
void Get_Score();
void DisplayAverage(double average);
double Test_Score1, Test_Score2, Test_Score3;
int main()
{
Get_Score();
DisplayAverage(calcAverage(Test_Score1, Test_Score2, Test_Score3));
return 0;
}
void Get_Score()
{
cout << "First Test: ";
cin >> Test_Score1;
cout << "Second Test: ";
cin >> Test_Score3;
cout << "Third Test: ";
cin >> Test_Score3;
}
void DisplayAverage(double average)
{
cout << fixed << setprecision(1);
cout << "Average Test_Score is: " << average << endl;
}
double calcAverage(double Test_Score1, double Test_Score2, double Test_Score3)
{
return (Test_Score1 + Test_Score2 + Test_Score3) / 3;
}
2)
Gross Pay
class Gross_Pay
{
private:
int hoursWorked;
double payRate;
public:
Gross_Pay();
Gross_Pay(int, double);
void setHoursWorked(int);
void setPayRate(double);
int getHoursWorked() const;
double getPayRate() const;
double calcGross()const;
};
Gross_Pay::Gross_Pay()
{
hoursWorked = 0;
payRate = 0.0;
}
Gross_Pay::Gross_Pay(int h, double r)
{
payRate = r;
hoursWorked = h;
}
void Gross_Pay::setHoursWorked(int h)
{
hoursWorked = h;
}
void Gross_Pay::setPayRate(double p)
{
payRate = p;
}
int Gross_Pay::getHoursWorked() const
{
return hoursWorked;
}
double Gross_Pay::getPayRate() const
{
return payRate;
}
double Gross_Pay::calcGross() const
{
double gross = static_cast<double>(hoursWorked) * payRate;
return gross;
}
using namespace std;
int main()
{
const int NUM_EMPLOYEES = 7;
Gross_Pay employee[NUM_EMPLOYEES];
int pay;
int hours;
int i;
double grossPay;
for (i = 0; i < NUM_EMPLOYEES; i++)
{
cout << "Enter the employee's rate of pay per hour: ";
cin >> pay;
cout << "Enter the employee's hours worked for the week: ";
cin >> hours;
employee[i].setPayRate(pay);
employee[i].setHoursWorked(hours);
}
cout << " Here is the gross pay for each employee: ";
cout << fixed << showpoint << setprecision(2);
for (int i = 0; i < NUM_EMPLOYEES; i++)
{
grossPay = employee[i].calcGross();
cout << "The gross pay for employee # " << (i) << " is: " << grossPay << endl;
}
return 0;
}
3) Tempareture
#include <iostream.h>
float totalFahrenheit(float);
float totalCelsius (float);
float main(float){
float temp;
int choice;
cout<<"Type in the temperature: ";
cin>>temp;
cout<<"Press 2 to convert to Celsius and press 1 to convert to Fahrenheit: ";
cin>>choice;
totalFahrenheit(temp);
totalCelsius(temp);
if (choice=='2')
{
cout<<temp<<" degrees Fahrenheit converted to Celsius is: "<<totalCelsius(temp);
}
else
if (choice=='1')
{
cout<<temp<<" degrees Celsius converted to Fahrenheit is: "<<totalFahrenheit(temp);
}
}
float totalFahrenheit(float temp){
return ((9/5*temp)+(32));
}
float totalCelsius (float temp){
return ((temp-32)*(5/9));
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.