I am new to Qaru and generally programming. I participate in several C ++ programming classes and come across a task that I am having problems with. This program should take Fahrenheit and transform it into a target. I saw other programs, but could not find a duplicate for my specific problem. This is my code.
#include <iostream>
using namespace std;
int main()
{
int fahrenheit;
cout << "Please enter Fahrenheit degrees: ";
cin >> fahrenheit;
int celsius = 5.0 / 9 * (fahrenheit - 32.0);
cout << "Celsius: " << celsius << endl;
return 0;
}
So, this works great on 4 of the 5 tests that run. It is rounded from 22.22 to 22 and from 4.44 to 4, as expected, but when 0 F is entered, it is rounded from -17.77 to -17 instead of -18. I worked for about an hour and will be happy to help! Thank.
source
share