Write a program that converts integer Fahrenheit temperatures from 0 to 212 degrees to floating-point 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.

What will be an ideal response?


```
#include
#include
using namespace std;

int main()
{
double celsius; // holds Celsius temperature

// create column headings with fields of length 20
cout << setw( 20 ) << "Fahrenheit " << setw( 20 ) << "Celsius\n"
<< fixed << showpoint;

// convert Fahrenheit to Celsius and display temperatures
// showing the sign for Celsius temperatures
for ( int fahrenheit = 0; fahrenheit <= 212; fahrenheit++ )
{
celsius = 5.0 / 9.0 * ( fahrenheit - 32 );
cout << setw( 15 ) << noshowpos << fahrenheit << setw( 23 )
<< setprecision( 3 ) << showpos << celsius << '\n';
} // end for
} // end main
```
Fahrenheit Celsius
0 -17.778
1 -17.222
2 -16.667
3 -16.111
4 -15.556
...
205 +96.111
206 +96.667
207 +97.222
208 +97.778
209 +98.333
210 +98.889
211 +99.444
212 +100.000

Computer Science & Information Technology

You might also like to view...

Within what time frame does the HITECH Act require covered entities to notify affected individuals of a data breach of personal healthcare information?

A) 30 days B) 40 days C) 60 days D) 1 week

Computer Science & Information Technology

A number in the second column of the third row of a Word table is considered to be in cell:

A) B3. B) C2. C) 2C. D) 3B.

Computer Science & Information Technology

In the System Stability Index chart, a ____ is a warning event, such as that a new driver installation has failed but the device is still working with the old driver.

A. yellow yield sign with an exclamation point B. yellow circle with an exclamation point C. red circle with an exclamation point D. blue circle with a question mark

Computer Science & Information Technology

Which of the following modes creates semitransparent shadow effects and multiplies the value of the base color by the blend color.

A. Enable airbrush B. Normal C. Multiply blend D. Color Layer

Computer Science & Information Technology