Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class AlcoholMarket_07 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- //1. read input -> price of whiskey, quantity whiskey, rakia, wine, beer
- //2. price of rakia = price of whiskey / 2
- //3. price of wine = price of rakia - 0.4 * price of rakia -> 0.6 * price of rakia
- //4. price of beer = price of rakia - 0.8 * price of rakia -> 0.2 * price of rakia
- //5. total price ( price of whiskey * quantity whiskey) + (price of rakia * quantity rakia)
- // + (price of wine * quantWine) + (price of beer * quantBeer)
- //6. print total price -> 2 (digit)
- double whiskeyPrice = Double.parseDouble(scanner.nextLine());
- double beerLiters = Double.parseDouble(scanner.nextLine());
- double wineLiters = Double.parseDouble(scanner.nextLine());
- double rakiaLiters = Double.parseDouble(scanner.nextLine());
- double whiskeyLiters = Double.parseDouble(scanner.nextLine());
- double rakiaPrice = whiskeyPrice / 2;
- double winePrice = rakiaPrice - 0.4 * rakiaPrice; // 0.6 * rakiaPrice
- double beerPrice = rakiaPrice - 0.8 * rakiaPrice; // 0.2 * rakiaPrice
- double totalPrice = (whiskeyPrice * whiskeyLiters)
- + (winePrice* wineLiters)
- + (rakiaPrice* rakiaLiters)
- +(beerPrice * beerLiters) ;
- System.out.printf("%.2f", totalPrice);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement