Question: The program currently accepts a celsius temperature from the user and converts it to the Fahrenheit equivalent. It then asks the user whether or not

The program currently accepts a celsius temperature from the user and converts it to the Fahrenheit equivalent. It then asks the user whether or not they would like to enter another temperature or terminate the program. I want you to modify the program to include the following features: (1) Ensure that the user is only allowed to enter a celsius temperate between 0 and 40. If the user enters a value outside of this range, display an error that says "You have entered an invalid temperature. The program will now terminate", and then terminate the program without performing any other operations (2) If the user enters more than one temperature, display the average Celsius value, and the equivalent Fahrenheit temperature, whenever the user has chosen to finish entering values.

Starting program:

#include using namespace std;

int main() { double celsiusTemp; double fahrenheitTemp; char shouldContinue;

do { cout << "Enter a celsius temperature that you would like to have converted to fahrenheit: " << endl; cin >> celsiusTemp; fahrenheitTemp = (celsiusTemp * 1.8) + 32; cout << celsiusTemp << " Degrees Celsius is equal to " << fahrenheitTemp << " Degrees Fahrenheit" << endl; cout << "Would you like to convert another temperature? Enter Y to continue, or N to terminate the program" << endl; cin >> shouldContinue; } while (shouldContinue == 'y' || shouldContinue == 'Y');

cout << "The program has ended. Thank you for using our conversion service." << endl;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!