Deiancom

Summer Shopping

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