Hi all,
I am doing the Temperture Converter problem on this site: Temperature Converter Programming Challenge - Cprogramming.com
I basically did a quick program and used the example numbers giving on the above site (10 for low, 20 high, 4 for the step). I am getting the "right answers" but they are intergers and have no decimal places but 2 of the answers should have decimal places. I declared the varibles with double and tried with float but I am getting the same answer. When I input (10.2 for low, 20 for high, 4 for step) all the answers come out with a .2 at the end so I know it can print decimal places.
Am I missing something here? like do I have to declare how many decimal places somewhere?
Here is my program below.
Code:
#include <cstdlib>
#include <iostream>
using namespace std;
void Celsius_to_Fahrenheit(double celsius_low, double celsius_high, int step);
int main()
{
double low_limit, high_limit;
int increments;
char exit;
cout<<"Enter low Celcius ";
cin>>low_limit;
cout<<"\nEnter high Celcius ";
cin>>high_limit;
cout<<"\nEnter the ingrements you would like it to calculate by ";
cin>>increments;
cout<<"\n\nCelsius Fahrenheit\n";
cout<<"_______ __________\n";
Celsius_to_Fahrenheit(low_limit, high_limit, increments);
cout<<"Press any key then enter to exit";
cin>>exit;
return 0;
}
void Celsius_to_Fahrenheit(double celsius_low, double celsius_high, int step)
{
double Fahrenheit;
while(celsius_high >= celsius_low)
{
Fahrenheit = 9/5 * (celsius_low + 32);
cout<<celsius_low<<" "<<Fahrenheit<<"\n";
celsius_low = celsius_low + step;
}
}