public class Centigrade_Fahrenheit
{
public static void main(String[] args)
{
int start = 0;
final int end = 20;
System.out.println("Centigrade \t Fahrenheit");
System.out.println("------------------------------");
while(start <= end)
{
double fahrenheit = (9/5) * start + 32;
System.out.println(start + "\t\t" + fahrenheit);
start++;
}
}
}
very quick code to display 0 to 20 centigrade degree and show its equivalents in fahrenheit. It work.. my program farenheit is like 9 or 8 degree off though. I notice in my program the farenheit show up as (33.00) instead of (33.8). what do i need to do to make the caculation more precise?

New Topic/Question
Reply



MultiQuote










|