forked from Programming-Club-IAU/Task-1.3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTempConv.java
More file actions
54 lines (46 loc) · 2.53 KB
/
TempConv.java
File metadata and controls
54 lines (46 loc) · 2.53 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import java.util.Scanner;
public class TempConv {
public static void main(String[] args){
// ASCII Art and instructions
System.out.println(" _ _______ _________ _ ______ _________ _ ");
System.out.println("( ( /|( ___ )|\\ /| \\__ __/( )( __ \\ |\\ /|\\__ __/( ( /|");
System.out.println("| \\ ( || ( ) || ) ( | ) ( |/ | ( \\ ) | ) ( | ) ( | \\ ( |");
System.out.println("| \\ | || (___) || (___) | | | | | ) | | | _ | | | | | \\ | |");
System.out.println("| (\\ \\) || ___ || ___ | | | | | | | | |( )| | | | | (\\ \\) |");
System.out.println("| | \\ || ( ) || ( ) | | | | | ) | | || || | | | | | \\ |");
System.out.println("| ) \\ || ) ( || ) ( | _ ___) (___ | (__/ ) | () () |___) (___| ) \\ |");
System.out.println("|/ )_)|/ \\||/ \\|( ) \\_______/ (______/ (_______)\\_______/|/ )_)");
System.out.println(" |/ ");
while(true){
try{
System.out.println("\nPlease select an option:");
System.out.println("1 - Convert Celsius to Fahrenheit");
System.out.println("2 - Convert Fahrenheit to Celsius");
System.out.println("3 - Exit");
Scanner input = new Scanner(System.in);
int choice = input.nextInt();
switch(choice){
case 1:
System.out.println("Enter temp in c");
System.out.println("Result : " + (input.nextDouble() * 9 / 5 + 32));
break;
case 2:
System.out.println("Enter temp in f");
System.out.println("Result : " + ((input.nextDouble() - 32) * 5 / 9));
break;
case 3:
System.out.print("Bye Bye !");
System.exit(0);
break;
default:
System.out.println("Wrong Choice");
break;
}
System.err.println("Done !");
}
catch(Exception e){
System.out.println("Something went wrong :( \nplease try again");
}
}
}
}