Advertisement
TheSTRIG

DiscountCounter

Jan 10th, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.33 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class DiscountCounter {
  4.     public static void main (String[] args){
  5.         Scanner in = new Scanner(System.in);
  6.         System.out.println("=============");
  7.         System.out.print("| Discount Counter   |");
  8.         System.out.print("\n=============");
  9.         counter();
  10.         for (int i = 1; i > 0; i++) {
  11.             System.out.print("Continue? (Y/N): ");
  12.             String a = in.nextLine();
  13.             if (a.equalsIgnoreCase("Y")) {
  14.                 counter();
  15.             } else if (a.equalsIgnoreCase("N")) {
  16.                 System.exit(0);
  17.             }
  18.         }
  19.     }
  20.    
  21.    
  22.     public static void counter(){
  23.         Scanner sc = new Scanner(System.in);
  24.        
  25.         System.out.print("\nEnter the price: ");
  26.         double price = sc.nextDouble();
  27.         System.out.print("Enter discount value: ");
  28.         double discount = sc.nextDouble();
  29.         System.out.println("With 10% PPN tax? (Y/N)");
  30.         String tax = sc.next();
  31.        
  32.         if (tax.equalsIgnoreCase("y")){
  33.             double ppn = 0.1;
  34.             double taxPrice = ppn * (price - (price * (discount/100)))  ;
  35.             double finalPrice = price - (price * (discount/100)) + taxPrice;
  36.             System.out.println("Price: " + finalPrice);
  37.             System.out.println("-----------------------------");
  38.         } else if (tax.equalsIgnoreCase("N")){
  39.             double finalPrice = price - (price * (discount/100));
  40.             System.out.println("Price: " + finalPrice);
  41.             System.out.println("-----------------------------");
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement