Advertisement
marking2112

Alcohol shop

Jun 6th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P18Alcohol {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         Double whiskey = Double.parseDouble(scanner.nextLine());
  8.         Double beerlitres = Double.parseDouble(scanner.nextLine());
  9.         Double winelitres = Double.parseDouble(scanner.nextLine());
  10.         Double brandylitres = Double.parseDouble(scanner.nextLine());
  11.         Double whiskeylitres = Double.parseDouble(scanner.nextLine());
  12.  
  13.         Double brandy = whiskey * 0.5;
  14.         Double wine = brandy - (0.4 * brandy);
  15.         Double beer = brandy - (0.8 * brandy);
  16.  
  17.         Double brandyprice = brandy * brandylitres;
  18.         Double wineprice = wine * winelitres;
  19.         Double beerprice = beer * beerlitres;
  20.         Double whiskeyprice = whiskey * whiskeylitres;
  21.  
  22.         Double result = brandyprice + wineprice + beerprice + whiskeyprice;
  23.  
  24.         System.out.printf("%.2f", result);
  25.        
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement