Advertisement
SUni2020

AlcoholMarket_07

Feb 16th, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.48 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class AlcoholMarket_07 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         //1. read input -> price of whiskey, quantity whiskey, rakia, wine, beer
  7.         //2. price of rakia = price of whiskey / 2
  8.         //3. price of wine = price of rakia - 0.4 * price of rakia -> 0.6 * price of rakia
  9.         //4. price of beer = price of rakia - 0.8 * price of rakia -> 0.2 * price of rakia
  10.         //5. total price ( price of whiskey * quantity whiskey) + (price of rakia * quantity rakia)
  11.         // + (price of wine * quantWine) + (price of beer * quantBeer)
  12.         //6. print total price -> 2 (digit)
  13.  
  14.         double whiskeyPrice = Double.parseDouble(scanner.nextLine());
  15.         double beerLiters = Double.parseDouble(scanner.nextLine());
  16.         double wineLiters = Double.parseDouble(scanner.nextLine());
  17.         double rakiaLiters = Double.parseDouble(scanner.nextLine());
  18.         double whiskeyLiters = Double.parseDouble(scanner.nextLine());
  19.  
  20.         double rakiaPrice = whiskeyPrice / 2;
  21.         double winePrice = rakiaPrice - 0.4 * rakiaPrice; // 0.6 * rakiaPrice
  22.         double beerPrice = rakiaPrice - 0.8 * rakiaPrice; // 0.2 * rakiaPrice
  23.  
  24.         double totalPrice = (whiskeyPrice * whiskeyLiters)
  25.                 + (winePrice* wineLiters)
  26.                 + (rakiaPrice* rakiaLiters)
  27.                 +(beerPrice * beerLiters) ;
  28.  
  29.         System.out.printf("%.2f", totalPrice);
  30.     }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement