what r menu driven programs and any five menu driven programs using switch case statements?
Answers
Answer:
import java.util.*;
public class bill4
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("the name of the person");
String s=sc.next();
System.out.println("the addres of the customer");
String a=sc.next();
System.out.println("the amount");
double amt=sc.nextDouble();
System.out.println("enter for laptop 1");
System.out.println("enter for desktop 2");
System.out.println("enter your choice");
int tell=sc.nextInt();
switch (tell)
{
case'1':laptop();break;
case'2':desktop();break; ;break;
default:System.out.println("invalid chice");
}
}
//laptop method
private void laptop()
{
if (amt>0&&amt<=25000)
dis=0.0%100;
else if(amt>25000&&amt<57000)
dis=5.0%100;
else if(amt>57000&&amt<1000000)
dis=7.5%100;
else if(amt>=1000000)
dis=10.0%100;
}
//desktop method
private void desktop()
{
if (amt>0&&amt<=25000)
dis=5.0%100;
else if(amt>25000&&amt<57000)
dis=7.5%100;
else if(amt>57000&&amt<1000000)
dis=10.0%100;
else if(amt>=1000000)
dis=15.0%100;
}
}
Explanation: