Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class P18Alcohol {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- Double whiskey = Double.parseDouble(scanner.nextLine());
- Double beerlitres = Double.parseDouble(scanner.nextLine());
- Double winelitres = Double.parseDouble(scanner.nextLine());
- Double brandylitres = Double.parseDouble(scanner.nextLine());
- Double whiskeylitres = Double.parseDouble(scanner.nextLine());
- Double brandy = whiskey * 0.5;
- Double wine = brandy - (0.4 * brandy);
- Double beer = brandy - (0.8 * brandy);
- Double brandyprice = brandy * brandylitres;
- Double wineprice = wine * winelitres;
- Double beerprice = beer * beerlitres;
- Double whiskeyprice = whiskey * whiskeylitres;
- Double result = brandyprice + wineprice + beerprice + whiskeyprice;
- System.out.printf("%.2f", result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement