Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a program that contains 4 methods/functions... main(), getTestScores(), c

ID: 3679212 • 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...main() should call a method called convertToFahrenheit to convert and return the new Fahrenheit equivalent temperature. If the given temperature is fahrenheit...main() 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

AverageTestScores.cpp

#include <iostream>
using namespace std;

double getTestScore();
double calcAverage( double scores);
double displayAverage(double calculatedAverage);

int main()
{
    //declare variables
    double score1 = 0.0;
    double testScore = 0.0;
    double average = 0.0;
    score1 = getTestScore();
    testScore = calcAverage(score1);
    displayAverage(testScore);
    return 0;
} //end of main function

double getTestScore()
{
    double score1;
double score2;
double score3;
double scores;

cout << "First Score: ";
cin >> score1;
cout << "Second Score: ";
cin >> score2;
cout << "Third Score: ";
cin >> score3;
scores = score1+score2+score3;
return scores;
}//end of getTestScore function

double calcAverage(double scores)
{
    double calculatedAverage = 0.0;
    calculatedAverage = (scores) / 3;
    return calculatedAverage;
} //end of calcAverage function

double displayAverage(double calculatedAverage)
{
        cout << "Average is: " << calculatedAverage << endl;
}

Output :

First Score: 76

Second Score: 68

Third Score: 66

Average is: 70

GrossPay.cpp

#include <iostream>
#include <iomanip>
using namespace std;

double getHoursWorked();
double getPayRate();
double calcGross(double workHours, double thePayRate);

int main()
{
    //declare variables
    double hoursWorked   = 0;
    double payRate   = 0;
    double grossPay   = 0;

    //enter input
    hoursWorked = getHoursWorked();
    payRate   = getPayRate();


    grossPay = calcGross(hoursWorked, payRate);

    //display the total points and grade
    cout << "Gross Pay: " << grossPay << endl;

    system("pause");
    return 0;
} //end of main function

double getHoursWorked()
{
    double hoursOfWork;
        cout << "Please enter hours worked: ";
        cin >> hoursOfWork;
    return hoursOfWork;
}//end of getHoursWorked function

double getPayRate()
{
    double rateOfPay;
        cout << "Please enter pay rate: ";
        cin >> rateOfPay;
    return rateOfPay;
}//end of getPayRate function

double calcGross(double workHours, double thePayRate)
{
    double calculatedGross = 0.0;
    calculatedGross = workHours * thePayRate;
    return calculatedGross;
} //end of calcAverage function

Output :

Please enter hours worked: 10

Please enter pay rate: 20

Gross Pay: 200

Temperature.cpp

#include <iostream>
using namespace std;
float celsius;
float fahrenheit;

void convertToCelsius()
{
   celsius = ((fahrenheit - 32) * 5) / 9;
}
void convertToFahrenheit()
{
   fahrenheit = (((celsius * 9) / 5) + 32);
}

int main()
{
   unsigned short choice;
   cout << "Welcome to the temperature converter. ";
   cout << "Please type '1' for Celsius to Fahrenheit conversion." << endl;
   cout << "Or, type '2' for Fahrenheit to Celsius conversion." << endl;
   cin >> choice;

   switch (choice)
{
   case 1:

   cout << "Please enter your temperature in Celsius. ";

   cin >> celsius;
   convertToFahrenheit();

   cout << " ";
   cout << "Computing... ";
   cout << "The temperature in Fahrenheit is " << fahrenheit << ". ";
   cout << "Press any key to terminate the program." << endl;
   cout << endl;
   break;

   case 2:

   cout << "Please enter your temperature in Fahrenheit. ";

   cin >> fahrenheit;
   convertToCelsius();

   cout << " ";
   cout << "Computing... ";
   cout << "The temperature in Celsius is " << celsius << ". ";
   cout << "Press any key to terminate the program." << endl;
   cout << endl;
   break;

   default:

   cout << "That is not an option!" << endl;
   cout << "Please close the program and try again." << endl;
   break;

}

   return 0;
}

Output

Welcome to the temperature converter.

Please type '1' for Celsius to Fahrenheit conversion.

Or, type '2' for Fahrenheit to Celsius conversion.

1

Please enter your temperature in Celsius.

100

Computing...

The temperature in Fahrenheit is 212.

Press any key to terminate the program.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote