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

Simple Fahrenheit to Celsius Conversion program in C++ -Contains a user-interfac

ID: 3769839 • Letter: S

Question

Simple Fahrenheit to Celsius Conversion program in C++

-Contains a user-interface function which requests the user to enter the maximum temperature as an int.

-If the maximum temperature entered is not an integer, the program must display an error message and prompt the user to re-enter the temperature.

-If the maximum temperature entered is less than or equal to 0, the program must display an error message and prompt the user to re-enter the temperature.

-Contains a function to round up the maximum temperature to the next multiple of 5 (For example 90 will remain 90, but 91 will become 95)

Contains a print function which uses a while loop to generate a table starting from 0 F to the maximum temperature in increments of 5 F

-Contains a function called convertFtoC with the following prototype:

// Uses the formula: C = (F - 32) * (5 / 9)

-The table output must be formatted.

-A sample output of your program is shown below. Columns for Celsius must have two decimal places and must be right aligned.

Example is shown below:

<Print a brief message to the user describing your program>

Please enter a maximum temperature in Fahrenheit (F): 93

Temperature in F Temperature in C 0 -17.77 5 ... 10 ... ... ... ... up to the maximum temp (in this case 95)

Explanation / Answer

#include <iostream>
#include <cctype>
using namespace std;
int main()
{
int temp, tempCon;
char unit;
cout << "Please enter the temperature and measurement system (c or f): ";
cin >> temp;
cin >> unit;
if ( isupper(unit) )
{
unit = tolower(unit);
}
if (unit == 'f')
{
temp = (temp - 32) / 9.0 * 5.0;
cout << temp << " degrees Celsius ";
}
else if (unit == 'c')
{
temp = 9.0 / 5.0 * temp + 32;
cout << temp << " degrees Fahrenheit ";
}
else
{
cout << "Sorry that unit of measure isn't recognized around here. ";
}
return 0;
}

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