Advertisement
Ivelin_Arsov

Summer Shoping

Feb 20th, 2020
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.15 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SummerShopping {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.         int budget = Integer.parseInt(scan.nextLine());
  7.         double towelPrice = Double.parseDouble(scan.nextLine());
  8.         int discount = Integer.parseInt(scan.nextLine());
  9.  
  10.         double umbrellaPrice = 2.0 / 3.0 * towelPrice;
  11.         double flipFlopsPrice = umbrellaPrice * 0.75;
  12.         double beachBagPrice = 1.0 / 3.0 * (towelPrice + flipFlopsPrice);
  13.         double totalgoodsPrice = towelPrice + umbrellaPrice +
  14.                 flipFlopsPrice + beachBagPrice;
  15.         double totalAfterDiscount = totalgoodsPrice - (totalgoodsPrice*1.0)/100 * discount;
  16.  
  17.  
  18.         if (budget >= totalAfterDiscount) {
  19.             double budgetLeft = budget - totalAfterDiscount;
  20.             System.out.printf("Annie's sum is %.2f lv. She has %.2f lv. left.", totalAfterDiscount, budgetLeft);
  21.         } else {
  22.             double budgetNeeded = totalAfterDiscount - budget;
  23.             System.out.printf("Annie's sum is %.2f lv. She needs %.2f lv. more.", totalAfterDiscount, budgetNeeded);
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement