- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction_celsius.java
More file actions
Latest commit
34 lines (25 loc) · 701 Bytes
/
Copy pathfunction_celsius.java
File metadata and controls
34 lines (25 loc) · 701 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
publicclasscelsiusfahrenheit
{
publicstaticvoidmain(String[] args)
{
doublecelsius = 6.0;
doublefahrenheit = 53.5;
display(fahrenheit(celsius), "F");
display(celsius(fahrenheit), "Grad");
}
//-------------------------------------------------------------------
staticdoublecelsius(doublex)
{
doubleresult = ((x-32) * 5/9);
returnresult;
}
staticdoublefahrenheit(doublex)
{
doubleresult = x * 9 / 5 + 32;
returnresult;
}
staticvoiddisplay(doublex, Stringeinheit)
{
System.out.printf("%.1f %s%n", x, einheit);
}
}