Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- class Temperature
- {
- BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
- int ch;
- double cel,Fah;
- void convert() throws IOException
- {
- System.out.println("1.Celsius to Fahrenheit");
- System.out.println("2.Fahrenheit to Celsius");
- System.out.println("Enter choice(1/2)");
- ch=Integer.parseInt(br.readLine());
- switch(ch)
- {
- case 1: System.out.println("Enter temperature in Celsius");
- cel=Double.parseDouble(br.readLine());
- Fah=(9*cel)/5+32;
- System.out.println("Converted temperature in Fahrenheit = "+Fah);
- break;
- case 2: System.out.println("Enter temperature in Fahrenheit");
- Fah=Double.parseDouble(br.readLine());
- cel=(Fah-32)*5/9;
- System.out.println("Converted temperature in Celsius = "+cel);
- break;
- default: System.out.println("Invalid choice");
- break;
- }
- }
- public static void main(String args[])
- {
- Temperature t=new Temperature();
- t.convert();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment