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