//java program Show the cost of registration according to discount and registration type:
import java.util.Scanner;
public class Discountnew
{
public static void main(String[] args)
{
int bill,ch,cust,rcost,c;
String name;
double dis,s,amount;
Scanner in = new Scanner(System.in);
System.out.println("Enter customer Name:");
name = in.nextLine();
System.out.println("Enter customer Number:");
cust = in.nextInt();
System.out .println("Check customer is new or existing Press 1 for
New Customer and Press any number for Exisiting Customer");
ch = in.nextInt();
int rtype=1;
System.out.println("\n\n 1.Register daily,Discount $5,2.Register
weekly $20, 3.Register monthly $40 4. Register annual $80");
if(ch==1 && rtype==1)
{
System.out.println("Enter user choice:");
c= in.nextInt();
double a;
switch(c)
{
case 1:
dis=10; // 10 mean 10%
rcost=5; //$5
s=100-dis;
amount= (s*rcost)/100;
System.out.println("After discount your bill is: " +
amount);
break;
case 2:
dis=10; // 10 mean 10%
rcost=20; //$20
s=100-dis;
amount= (s*rcost)/100;
System.out.println("After discount your bill is: " +
amount);
break;
case 3:
dis=10; // 10 mean 10%
rcost=40; //$40
s=100-dis;
amount= (s*rcost)/100;
System.out.println("After discount your bill is: " +
amount);
break;
case 4:
dis=10; // 10 mean 10%
rcost=80; //$80
s=100-dis;
amount= (s*rcost)/100;
System.out.println("After discount your bill is: " +
amount);
break;
default:
System.out.println("Invalid choice");
}
}
else if(ch==2 && rtype==1)
{
System.out.println("Enter user choice:");
c= in.nextInt();
double a;
switch(c)
{
case 1:
dis=5; // 5 mean 5%
rcost=5; //$5
s=100-dis;
amount= (s*rcost)/100;
System.out.println("After discount your bill is: " +
amount);
break;
case 2:
dis=5; // 5 mean 5%
rcost=20; //$20
s=100-dis;
amount= (s*rcost)/100;
System.out.println("After discount your bill is: " +
amount);
break;
case 3:
dis=5; // 5 mean 5%
rcost=40;//$40
s=100-dis;
amount= (s*rcost)/100;
System.out.println("After discount your bill is: " +
amount);
break;
case 4:
dis=5; // 5 mean 5%
rcost=80;//$80
s=100-dis;
amount= (s*rcost)/100;
System.out.println("After discount your bill is: " +
amount);
break;
default:
System.out.println("Invalid choice");
}
}
else
{
System.out.println("Invalid choice");
}
}
}
Output:
Get Answers For Free
Most questions answered within 1 hours.