Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SummerShopping {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int budget = Integer.parseInt(scan.nextLine());
- double towelPrice = Double.parseDouble(scan.nextLine());
- int discount = Integer.parseInt(scan.nextLine());
- double umbrellaPrice = 2.0 / 3.0 * towelPrice;
- double flipFlopsPrice = umbrellaPrice * 0.75;
- double beachBagPrice = 1.0 / 3.0 * (towelPrice + flipFlopsPrice);
- double totalgoodsPrice = towelPrice + umbrellaPrice +
- flipFlopsPrice + beachBagPrice;
- double totalAfterDiscount = totalgoodsPrice - (totalgoodsPrice*1.0)/100 * discount;
- if (budget >= totalAfterDiscount) {
- double budgetLeft = budget - totalAfterDiscount;
- System.out.printf("Annie's sum is %.2f lv. She has %.2f lv. left.", totalAfterDiscount, budgetLeft);
- } else {
- double budgetNeeded = totalAfterDiscount - budget;
- System.out.printf("Annie's sum is %.2f lv. She needs %.2f lv. more.", totalAfterDiscount, budgetNeeded);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement