Write a java program on the 27 question plz fast
Attachments:
Answers
Answered by
1
import java.util.*;
public class Electronics
{
public void comp()
{
Scanner sc=new Scanner (System.in);
System.out.println("Menu\n L:Laptop\nD:Desktop);
System.out.println("Enter your choice");
String ch=sc.next();
System.out.println("Enter your name");
String s=sc.nextLine();
System.out.println("Enter your address");
String add=sc.nextlLine();
System.out.println("Enter amount of purchase");
double amt=sc.nextDouble();
double discount, netamt;
switch(ch)
{
case L: System.out.println("You have chosen to buy Laptop");
if(amt<=25000)
discount=0.0;
else if(amt >=25001 && amt<=57000)
discount=(5.0/100.0)*amt;
else if (amt>=57001 && amt<=100000)
discount=(7.5/100.0)* amt;
else if(amt>100000)
discount=(10.0/100)*amt;
break;
case D: System.out.println("You have chosen to buy Desktop");
if(amt<=25000)
discount=(5.0/100.0)*amt
else if(amt >=25001 && amt<=57000)
discount=(7.5/100.0)*amt;
else if (amt>=57001 && amt<=100000)
discount=(10.0/100.0)* amt;
else if(amt>100000)
discount=(15.0/100)*amt;
break;
default: System.out.println("Invalid choice");
}
net amt= amt-discount;
System.out.println("Name:" +n);
System.out.println("Address:" +add);
System.out.println("Net Amount: " +netamt);
}
}
public class Electronics
{
public void comp()
{
Scanner sc=new Scanner (System.in);
System.out.println("Menu\n L:Laptop\nD:Desktop);
System.out.println("Enter your choice");
String ch=sc.next();
System.out.println("Enter your name");
String s=sc.nextLine();
System.out.println("Enter your address");
String add=sc.nextlLine();
System.out.println("Enter amount of purchase");
double amt=sc.nextDouble();
double discount, netamt;
switch(ch)
{
case L: System.out.println("You have chosen to buy Laptop");
if(amt<=25000)
discount=0.0;
else if(amt >=25001 && amt<=57000)
discount=(5.0/100.0)*amt;
else if (amt>=57001 && amt<=100000)
discount=(7.5/100.0)* amt;
else if(amt>100000)
discount=(10.0/100)*amt;
break;
case D: System.out.println("You have chosen to buy Desktop");
if(amt<=25000)
discount=(5.0/100.0)*amt
else if(amt >=25001 && amt<=57000)
discount=(7.5/100.0)*amt;
else if (amt>=57001 && amt<=100000)
discount=(10.0/100.0)* amt;
else if(amt>100000)
discount=(15.0/100)*amt;
break;
default: System.out.println("Invalid choice");
}
net amt= amt-discount;
System.out.println("Name:" +n);
System.out.println("Address:" +add);
System.out.println("Net Amount: " +netamt);
}
}
Answered by
1
For executing any java program, you need toinstall the JDK if you don't have installed it, download the JDK and install it.set path of the jdk/bin directory. create the java programcompile and run the java program
Similar questions