write a menu-driven program in Java to perform either of the following conversions depending on the User's Choice (i) km to cm (ii) Hours to minutes (iii) Centigrade to Fahrenheit
Answers
Answer:
Program:-
import java.util.*;
public class Main
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
int ch;
System.out.println("Enter 1 to convert kilometre to centimetre");
System.out.println("Enter 2 to convert hours to minutes");
System.out.println("Enter 3 to convert centigrate to fahrenheit");
System.out.println("Enter your choice");
ch=in.nextInt();
switch(ch)
{
case 1:
int km,cm=0;
System.out.println("Enter the distance in km");
km=in.nextInt();
cm=km*100000;
System.out.println("The distance in centimetre="+cm);
break;
case 2:
int hr,min=0;
System.out.println("Enter the time in hours");
hr=in.nextInt();
min=hr*60;
System.out.println("The time in minutes="+min);
break;
case 3:
int c;
double f=0;
System.out.println("Enter the temperature in centigrate");
c=in.nextInt();
f=(9.0/5.0*c)+32;
System.out.println("The temperature in fahrenheit="+f);
break;
default:
System.out.println("Invalid Choice");
}
}
}
Output is attached.
Answer:
i know the answer.
Explanation:
the answer is;
go and watch Euro Cup and stay happy , relaxed,and chilled.
thank you