forked from Programming-Club-IAU/Task-1.3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask.java
More file actions
39 lines (33 loc) · 1.3 KB
/
Task.java
File metadata and controls
39 lines (33 loc) · 1.3 KB
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
33
34
35
36
37
38
39
import java.util.Scanner;
public class Task {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String input;
Scanner scanner2 = new Scanner(System.in);
Double temp;
while (true) {
System.out.print("\n"+"chose conversoin type( type 1 for: Celsius to Fahrenheit, type 2 for: Fahrenheit to Celsius, type 3 for: Exit): ");
input = scanner.nextLine();
if (input.equalsIgnoreCase("3")) {
System.out.println("Goodbye!");
break;
}
else if (input.equalsIgnoreCase("1")){
System.out.print("enter the temperature:");
temp = scanner2.nextDouble();
temp = (temp*1.8)+32;
System.out.print("the temperature in Fahrenheit is: ");
System.out.print(temp);
}
else if (input.equalsIgnoreCase("2")){
System.out.print("enter the temperature:");
temp = scanner2.nextDouble();
temp = (temp-32)/1.8;
System.out.print("the temperature in Celsius is: " + temp);
}
else{
System.out.println(" plese enter one of the following numbers (1,2,3)");
}
}
}
}