Back To Java Flow of Control Index
//program to convert fahrenheit temp to celsius and vice versa using switch statement public class tempcelsiusswitch { public static void main(String[] args) { int choice; double temp,conv; choice=1; switch(choice) { case 1: temp=90; conv=(temp-32)/1.8; System.out.println("temperature in celsius is " + conv); break; case 2: temp=40; conv=(1.8*temp)+32; System.out.println("temperature in fahrenheit is " + conv); break; default: System.out.println("enter choice 1 or 2 "); } } }