Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double packageRetail = 99;
- double quantity;
- double discount;
- double purchase;
- System.out.println("How many packages you want to buy?");
- quantity = scanner.nextDouble();
- if (quantity >= 100)
- {
- discount = 0.5;
- System.out.println("Discount: " + discount + "%");
- purchase = (packageRetail * quantity) * discount;
- System.out.println("Total amount of purchase after discount: " + purchase);
- }
- else if (quantity >= 50 && quantity <= 99)
- {
- discount = 0.4;
- System.out.println("Discount: " + discount + "%");
- purchase = (packageRetail * quantity) * discount;
- System.out.println("Total amount of purchase after discount: $" + purchase);
- }
- else if (quantity >= 20 && quantity <= 49)
- {
- discount = 0.3;
- System.out.println("Discount: " + discount + "%");
- purchase = (packageRetail * quantity) * discount;
- System.out.println("Total amount of purchase after discount: $" + purchase);
- }
- else if (quantity >= 10 && quantity <= 19)
- {
- discount = 0.2;
- System.out.println("Discount: " + discount + "%");
- purchase = (packageRetail * quantity) * discount;
- System.out.println("Total amount of purchase after discount: $" + purchase);
- }
- else
- {
- System.out.println("No discount");
- purchase = packageRetail * quantity;
- System.out.println("Total amount of purchase: $" + purchase);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment