Advertisement
TheSTRIG

DiscountCounter

Dec 29th, 2014
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 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.         double finalPrice = price - (price * (discount/100));
  30.        
  31.         System.out.println("Price: " + finalPrice);
  32.         System.out.println("-----------------------------");
  33.     }
  34.    
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement