Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class DiscountCounter {
- public static void main (String[] args){
- Scanner in = new Scanner(System.in);
- System.out.println("=============");
- System.out.print("| Discount Counter |");
- System.out.print("\n=============");
- counter();
- for (int i = 1; i > 0; i++) {
- System.out.print("Continue? (Y/N): ");
- String a = in.nextLine();
- if (a.equalsIgnoreCase("Y")) {
- counter();
- } else if (a.equalsIgnoreCase("N")) {
- System.exit(0);
- }
- }
- }
- public static void counter(){
- Scanner sc = new Scanner(System.in);
- System.out.print("\nEnter the price: ");
- double price = sc.nextDouble();
- System.out.print("Enter discount value: ");
- double discount = sc.nextDouble();
- System.out.println("With 10% PPN tax? (Y/N)");
- String tax = sc.next();
- if (tax.equalsIgnoreCase("y")){
- double ppn = 0.1;
- double taxPrice = ppn * (price - (price * (discount/100))) ;
- double finalPrice = price - (price * (discount/100)) + taxPrice;
- System.out.println("Price: " + finalPrice);
- System.out.println("-----------------------------");
- } else if (tax.equalsIgnoreCase("N")){
- double finalPrice = price - (price * (discount/100));
- System.out.println("Price: " + finalPrice);
- System.out.println("-----------------------------");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement