Sale.java.html

  1  import java.util.Scanner;
  2  
  3  public class Sale
  4  {
  5     public static void main(String[] args)
  6     {
  7        Scanner in = new Scanner(System.in);
  8  
  9        System.out.print("Original price before discount: ");
 10        double originalPrice = in.nextDouble();
 11  
 12        double discountRate;
 13        if (originalPrice < 128)
 14        {
 15           discountRate = 0.92;
 16        }
 17        else
 18        {
 19           discountRate = 0.84;
 20        }
 21        double discountedPrice = discountRate * originalPrice;
 22  
 23        System.out.printf("Discounted price: %.2f\n", discountedPrice);
 24     }
 25  }