Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Accidental Data Scientist

Authors: Amy Affelt

1st Edition

1573877077, 9781573877077

More Books

Students also viewed these Databases questions