Modify this code to display the message "That's hot!" if the temperature entered is greater than 90 degrees Farenheit or equivalent Celsius, or the message "That's cold!" if the temperature entered is less than -10 degrees Farenheit or equivalent Celsius. And to show one in between where it doesn't show any message. #include <iostream> #include <iomanip> using namespace std; // a temperature conversion program int main() { char tempType; double temp, fahren, celsius; cout << "Enter the temperature to be converted: "; cin >> temp; cout << "Enter an f if the temperature is in Fahrenheit"; cout << "\n or a c if the temperature is in Celsius: "; cin >> tempType; // set output formats cout << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2); if (tempType == 'f') { celsius = (5.0 / 9.0) * (temp - 32.0); cout << "\nThe equivalent Celsius temperature is " << celsius << endl; } else { fahren = (9.0 / 5.0) * temp + 32.0; cout << "\nThe equivalent Fahrenheit temperature is " << fahren << endl; } return 0; }
I have modified the code as requeired.
I have added comments // hot temperature and // cold temperature before printing the message
Please find updated code
/* Modify this code to display the message "That's hot!"
if the temperature entered is greater than 90 degrees
Farenheit or equivalent Celsius, or the message
"That's cold!" if the temperature entered is less than -10
degrees
Farenheit or equivalent Celsius.
And to show one in between where it doesn't show any message.
*/
#include <iostream>
#include <iomanip>
using namespace std;
// a temperature conversion program
int
main ()
{
char tempType;
double temp, fahren, celsius;
cout << "Enter the temperature to be converted: ";
cin >> temp;
cout << "Enter an f if the temperature is in
Fahrenheit";
cout << "\n or a c if the temperature is in Celsius: ";
cin >> tempType;
// set output formats
cout << setiosflags (ios::fixed) << setiosflags
(ios::
showpoint)
<<
setprecision (2);
if (tempType == 'f')
{
// hot temperature
if (temp > 90)
cout << "\n That's hot!" << endl;
// cold temperature
else if (temp < -10)
cout << "\n That's cold!" << endl;
celsius = (5.0 / 9.0) * (temp - 32.0);
cout << "\nThe equivalent Celsius temperature is " <<
celsius << endl;
}
else
{
// hot temperature
if (temp > 32.22)
cout << "\n That's hot!" << endl;
// cold temperature
else if (temp < -23.33)
cout << "\n That's cold!" << endl;
celsius = (5.0 / 9.0) * (temp - 32.0);
fahren = (9.0 / 5.0) * temp + 32.0;
cout << "\nThe equivalent Fahrenheit temperature is "
<< fahren <<
endl;
}
return 0;
}
Modify this code to display the message "That's hot!" if the temperature entered is greater than...
C++ code for CIS054 Create a program that uses a function to determine the length of a line by inputting the X,Y coordinates of the line endpoints. Show the result with a precision of four decimal places. The function prototype is to be specified as follows: double LengthOfLine (double X1, double Y1, double X2, double Y2); // returns length of line by using this code: #include <iostream> #include <iomanip> #include <cmath> using namespace std; int main(int argc, char* argv[])...
C++ programming I need at least three test cases for the program and at least one test has to pass #include <iostream> #include <string> #include <cmath> #include <iomanip> using namespace std; void temperatureCoverter(float cel){ float f = ((cel*9.0)/5.0)+32; cout <<cel<<"C is equivalent to "<<round(f)<<"F"<<endl; } void distanceConverter(float km){ float miles = km * 0.6; cout<<km<<" km is equivalent to "<<fixed<<setprecision(2)<<miles<<" miles"<<endl; } void weightConverter(float kg){ float pounds=kg*2.2; cout<<kg<<" kg is equivalent to "<<fixed<<setprecision(1)<<pounds<<" pounds"<<endl; } int main() { string country;...
I need to get this two last parts of my project done by tonight. If you see something wrong with the current code feel free to fix it. Thank you! Project 3 Description In this project, use project 1 and 2 as a starting point and complete the following tasks. Create a C++ project for a daycare. In this project, create a class called child which is defined as follows: private members: string First name string Last name integer Child...
The following is a program from Starting out with C++ by Toni Gaddis. I am getting the following error messages pertaining to the lines: cin>>month[i].lowTemp; and months[i].avgTemp = (months[i].highTemp + month[i].lowTemp)/2; The error messages read as follows: error C2039: 'lowTemp': is not a member of 'std::basic_string<_Elem,_Traits,_Ax>' and it continues. The second error message is identical. The program is as follows: Ch. 11, Assignment #3. pg. 646. Program #4. //Weather Statistics. //Write a program that uses a structure to store the...
Rework this project to include a class. As explained in class, your project should have its functionalities moved to a class, and then create each course as an object to a class that inherits all the different functionalities of the class. You createclass function should be used as a constructor that takes in the name of the file containing the student list. (This way different objects are created with different class list files.) Here is the code I need you...