-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExerciseSeven.java
More file actions
28 lines (19 loc) · 845 Bytes
/
Copy pathExerciseSeven.java
File metadata and controls
28 lines (19 loc) · 845 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
package UnitTwo;
import java.util.Scanner;
public class ExerciseSeven {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
System.out.println("Enter temperature: ");
int temperature = scanner.nextInt();
System.out.println("If you want to convert from Celsius to Fahrenheit enter 1 " +
"If you want to convert from Fahrenheit to Celsius enter 2 ");
int typeTemperature = scanner.nextInt();
if(typeTemperature==2){
System.out.println("temperature in Celsius is: " + ((temperature-32) * (5.0 / 9.0)));
}else if(typeTemperature==1) {
System.out.println("Temperature in Fahrenheit is: " + ((temperature * (9.0 / 5.0)) + 32));
}else {
System.out.println("Not valid data");
}
}
}