-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTemperatureConverter.java
More file actions
28 lines (22 loc) · 932 Bytes
/
TemperatureConverter.java
File metadata and controls
28 lines (22 loc) · 932 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
import java.util.Scanner;
public class TemperatureConverter {
public static void main( String args [] ) {
Scanner input = new Scanner( System.in );
System.out.println( "TEMPERATURE CONVERSOR!\n" );
System.out.println( "Enter celsius degrees to convert to other temperature measurements:" );
double celciusDegrees = input.nextLong();
System.out.println( "\n" + celciusDegrees + "°C in:" );
System.out.println("-Fahrenheit: " + fahrenheit( celciusDegrees ) );
System.out.println("-Kelvin: " + kelvin( celciusDegrees ) );
System.out.println("-Rankine: " + rankine( celciusDegrees ) );
}
static double fahrenheit( double celciusDegrees ) {
return ( ( celciusDegrees * 1.8 ) + 32 );
}
static double kelvin( double celciusDegrees ) {
return ( celciusDegrees + 273.15 );
}
static double rankine( double celciusDegrees ) {
return ( ( celciusDegrees * 1.8 ) + 491.67 );
}
}