-
Notifications
You must be signed in to change notification settings - Fork 0
/
SummerCollectionDiscountShop.java
86 lines (71 loc) · 3.2 KB
/
SummerCollectionDiscountShop.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package com.Conditionals;
import java.util.Scanner;
public class SummerCollectionDiscountShop {
public static float discount(int ...var){
float off=(float) var[0]/100;
float discountedamot=off*var[1];
return var[1]-discountedamot;
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("Assalam o alaikum, MAM");
int numberofitem;
int totalamount;
int saleprice;
System.out.println("What categray of item you want to buy?Select from the given choices");
System.out.println("| 1)Bags 2)Dress 3)Perfumes 4)Badsheets");
float selecitemprice;
int sum=0;
while (true) {
int input= sc.nextInt();
switch (input) {
case 1 -> {
System.out.println("25% off on bags (initila price is 3000)");
System.out.println("Enter no of items to buy:");
numberofitem = sc.nextInt();
saleprice = 3000;
totalamount = numberofitem * saleprice;
selecitemprice=discount(25,totalamount);
System.out.println("Total Amount to pay :"+selecitemprice);
sum +=selecitemprice;
}
case 2 -> {
System.out.println("35% off on Dress (initila price is 4000)");
System.out.println("Enter no of items to buy:");
numberofitem = sc.nextInt();
saleprice = 4000;
totalamount = numberofitem * saleprice;
selecitemprice=discount(35,totalamount);
System.out.println("Total Amount to pay :"+selecitemprice);
sum +=selecitemprice;
}
case 3 -> {
System.out.println("15% off on perfumes (initila price is 1500)");
System.out.println("Enter no of items to buy:");
numberofitem = sc.nextInt();
saleprice = 1500;
totalamount = numberofitem * saleprice;
selecitemprice=discount(15,totalamount);
System.out.println("Total Amount to pay :"+selecitemprice);
sum +=selecitemprice;
}
case 4 -> {
System.out.println("50% off on Badsheets (initila price is 5500)");
System.out.println("Enter no of items to buy:");
numberofitem = sc.nextInt();
saleprice = 5500;
totalamount = numberofitem * saleprice;
selecitemprice=discount(50,totalamount);
System.out.println("Total Amount to pay :"+selecitemprice);
sum +=selecitemprice;
}
}
System.out.println("Do you shop more:");
String ch=sc.next();
if(ch.equals("n")){
break;
}
}
System.out.println("Total amount to pay : "+sum);
}
}