Having problem with setprecision.

I am having problem with my code printing out the Celsius 1 decimal place to the right. It is currently printing out two to the right.

[code]
#include <iostream>
#include <iomanip>
using namespace std;

double get_celsius(double f);

int main()
{
double celsius;
cout << "Temperature Conversion Table\n\n";
cout << "Fahrenheit Celsius\n"
<< "____________________\n";

// Set output format
cout << fixed << showpoint << setprecision(1);

for (int fahrenheit = 0; fahrenheit <= 20; fahrenheit++)
{
celsius = get_celsius(fahrenheit);
cout << fixed;
cout << setprecision(1);
cout << fahrenheit << '\t' << celsius << endl;

//Place value returned by the function into the celsius variable
//Print out the fahrenheit and celsius variable with 1 place after the decimal
//Use iomanip, setprecision, fixed, showpoint

}

return 0;
}
double get_celsius (double f)
{
double celsius = 0.0f;
celsius = ((5.0 / 9) * (f - 32)); //equation of conversion from farenheit to celsius
return celsius; //(5 / 9) * (f - 32); (this will return to the int main function
}
I tested your code and my output had celsius with one decimal place. Do you want it to have 2?
Topic archived. No new replies allowed.