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

Revisit the Fahrenheit-Celsius conversion program you did in Assignment 1 (if yo

ID: 3573452 • Letter: R

Question

Revisit the Fahrenheit-Celsius conversion program you did in Assignment 1 (if you have not done Assignment 1, email me to get a solution). Add one of the loop statements (for, while, or do-while) you learned in chapter 5 to enable the user to perform multiple conversions of temperatures per session instead of just only 1. The number of temperatures to be converted (must be greater than 0) is entered by the user. For example, since the test table in Assignment 1 contains 3 temperatures to be converted (namely, 37.6, 90.5 and 120.7), the user enters 4 as shown in the following sample run of the program: Please enter the number of temperatures to be converted> 3 Please enter the temperature in Fahrenheit> 37.6 The corresponding temperature in Celsius is 3.1 Please enter the temperature m Fahrenheit> 90.5 The corresponding temperature in Celsius is 32.5 Please enter the temperature in Fahrenheit> 120.7 The corresponding temperature in Celsius is 49.3 Your program should also support error checking for the number of temperatures. If the number entered is less or equal 0, an error message should be displayed and should repeat until the user enters a valid number as follows Please enter the number of temperatures to be converted> 0 Invalid number. Please Please enter the number of temperatures to be converted> -2 Invalid number Please Please enter the number of temperatures to be converted> 3 Please enter the temperature in Fahrenheit> 37.6 The corresponding temperature in Celsius is 3.1 Please enter the temperature in Fahrenheit> 90.5 The corresponding temperature in Celsius is 32.5 Please enter the temperature in Fahrenheit> 120.7 The corresponding temperature in Celsius is 49.3

Explanation / Answer

#include <iostream>
using namespace std;

int main() {
float cel;
float fahr;
int count;
int i;
cout << "Please enter number of temprature to be converted" << endl;
cin >> count;

if(count > 0){

for(i = 0 ;i<count;i++){

cout << "Please Enter number in Farenheit." << endl;
cin >> cel;
if (cel > 0) { // (1)
fahr = 1.8 * cel + 32;
cout << "Fahrenheit = " << fahr << endl;
}else{
cout << "Please enter valid value";
break;
}
}
}
else{

cout << "Invalid Input";

}
}

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