Convert to Celsius using Methods 01-27-2014, 02:31 AM
#1
So can anyone convert Celsius using loops and methods? Here are some specific instructions:
Celsius Temperature Table
Where F is the Fahrenheit temperature and C is the Celsius temperature. Write a method named Celsius that accepts a Fahrenheit temperature as an argument. The method should return the temperature, converted to Celsius. Demonstrate the method by calling it in a loop that displays a table of the Fahrenheit temperature 0 to 20 and their Celsius equivalents.
I started you off can you finish and modify?
Celsius Temperature Table
Where F is the Fahrenheit temperature and C is the Celsius temperature. Write a method named Celsius that accepts a Fahrenheit temperature as an argument. The method should return the temperature, converted to Celsius. Demonstrate the method by calling it in a loop that displays a table of the Fahrenheit temperature 0 to 20 and their Celsius equivalents.
I started you off can you finish and modify?
Code:
public class conversiontable
{
public static void main(String [] args)
{
System.out.println("The following is a table that converts Celsius to Fahrenheit:");
System.out.println("Celsius Fahrenheit");
for (int c= 0; c <= 20; c= c+1)
{
int convertf= (c*9/5)+32;
int f= convertf;
System.out.println(+c+" "+f);
}
}
}
/* The following is a table that converts Celsius to Fahrenheit:
Celsius Fahrenheit
0 32
1 33
2 35
3 37
4 39
5 41
6 42
7 44
8 46
9 48
10 50
11 51
12 53
13 55
14 57
15 59
16 60
17 62
18 64
19 66
20 68
*/
![[Image: hB771xr.png?1?5086]](http://i.imgur.com/hB771xr.png?1?5086)
![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)