Q001_Discount_Offers
import java.util.*;
public class DiscountOffers {
public static void main(String[] args) {
Map<Integer, Integer> productPrices = new HashMap<>();
productPrices.put(1, 469);
productPrices.put(2, 469);
productPrices.put(3, 625);
productPrices.put(4, 625);
productPrices.put(5, 1000);
productPrices.put(6, 899);
productPrices.put(7, 999);
productPrices.put(8, 625);
productPrices.put(9, 725);
productPrices.put(10, 500);
System.out.println("Select the products from the below list:");
System.out.println("1) Women T-shirts - Rs.469");
System.out.println("2) Men T-shirts - Rs.469");
System.out.println("3) Kids T-shirts - Rs.625");
System.out.println("4) Women Ethnic Wear - Rs.625");
System.out.println("5) Men Formals - Rs.1000");
System.out.println("6) Women Western Wear - Rs.899");
System.out.println("7) Kids Night Suit - Rs.999");
System.out.println("8) Men Jeans - Rs.625");
System.out.println("9) Women Sarees - Rs.725");
System.out.println("10) Girl Skirts - Rs.500");
Scanner sc = new Scanner(System.in);
System.out.println("How many products you want to purchase?");
int n = sc.nextInt();
int totalAmount = 0;
System.out.println("Enter products purchased:");
for (int i = 0; i < n; i++) {
System.out.print("Product Number: ");
int productNumber = sc.nextInt();
if (productPrices.containsKey(productNumber)) {
totalAmount += productPrices.get(productNumber);
} else {
System.out.println("Invalid product number!");
if (n >= 5 && totalAmount > 3000 && totalAmount % 10 == 5) {
System.out.println("Congrats! You are eligible for 50% discount on your total purchase.");
System.out.println("Your actual total is " + totalAmount);
System.out.println("Your total amount after discount is " + (totalAmount / 2));
} else {
System.out.println("Better luck next time!!");
System.out.println("Your total purchase amount " + totalAmount);
sc.close();
Output:
Input 1:
Select the products from the below list
1)Women T-shirts - Rs.469
2)Men T-shirts - Rs.469
3)Kids T-shirts - Rs.625
4)Women Ethnic Wear - Rs.625
5)Men Formals - Rs.1000
6)Women Western Wear - Rs.899
7)Kids Night Suit - Rs.999
8)Men Jeans - Rs.625
9)Women Sarees - Rs.725
10)Girl Skirts - Rs.500
How many products you want to purchase?
5
Enter products purchased
Product Number: 5
Product Number: 5
Product Number: 5
Product Number: 4
Product Number: 5
Output 1:
Congrats! You are eligible for 50% discount on your total purchase..
Your actual total is 4625
Your total amount after discount is 2312
Input 2:
Select the products from the below list
1)Women T-shirts - Rs.469
2)Men T-shirts - Rs.469
3)Kids T-shirts - Rs.625
4)Women Ethnic Wear - Rs.625
5)Men Formals - Rs.1000
6)Women Western Wear - Rs.899
7)Kids Night Suit - Rs.999
8)Men Jeans - Rs.625
9)Women Sarees - Rs.725
10)Girl Skirts - Rs.500
How many products you want to purchase?
6
Enter products purchased
Product Number: 1
Product Number: 2
Product Number: 5
Product Number: 6
Product Number: 9
Product Number: 10
Output 2:
Better luck next time!!
Your total purchase amount 4062