Sep 24, 2015 at 10:13am
How can I made the answer display 18 when I enter 0 for fahrenheit
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
float fahrenheit;
float celsius;
cout << "Enter Fahrenheit: ";
cin >> fahrenheit;
celsius = 5.0 / 9 * (fahrenheit - 32);
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(0);
cout << "Celsius: " << static_cast<int>(celsius) << endl;
return 0;
|
Last edited on Sep 24, 2015 at 10:14am
Sep 24, 2015 at 10:27am
0 degrees fahrenheit in Celsius is -17.778 isn't it?
Sep 24, 2015 at 10:39am
try http://www.cplusplus.com/reference/cmath/round/
Sep 24, 2015 at 4:22pm
Thank you so much all of you. That is just what I needed. I'm super grateful. I solved it. JLBorges that is what I wanted to do. I did it. Thanks.