13,052,494 members (77,338 online)
Rate this:
See more:
Could someone help solve this c++ problem which is based on stream input/output..

Write a program that converts integer Fahrenheit temperatures from 0 to 212 degrees to floatingpoint
Celsius temperatures with 3 digits of precision. Use the formula
celsius = 5.0 / 9.0 * ( fahrenheit - 32 );
to perform the calculation. The output should be printed in two right justified columns and the
Celsius temperatures should be preceded by a sign for both positive and negative values...

Your help will be greatly appreciated.
Posted 5-May-13 22:50pm
Ian A Davidson 6-May-13 4:51am

Sounds like homework to me. Have you tried anything yourself yet?
Jopa Tidman 6-May-13 6:25am

Yes, just trying to confirm my answer. Here's my solution code..

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
float cel = 0;
cout << setprecision(1) << fixed; //sets 1 decimal place (fixed makes it decimals instead of digits)
cout << "Fahrenheit\tCelsius" << endl;
for( int i = 0; i <= 212; i += 1)
{
cel = (5.0/9.0)*double(i-32);//calculation happens here.
cout << i << "\t" << cel << endl;
}
system ("pause");
return 0;
}

Rate this:

## Solution 1

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!
Rate this:

## Solution 2

Top Experts
Last 24hrsThis month
 OriginalGriff 275 David_Wimbley 100 Jochen Arndt 95 Richard MacCutchan 95 ppolymorphe 90
 OriginalGriff 5,556 RickZeeland 1,954 ppolymorphe 1,848 F-ES Sitecore 1,636 Richard MacCutchan 1,429