Advertisement
Valantina

SummerShoppring/Ex/27.07.2019/Java

Jul 29th, 2019
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.00 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P02_SummeShoppring {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.  
  7.         int budget = Integer.parseInt(scan.nextLine());
  8.         double towelPrice = Double.parseDouble(scan.nextLine());
  9.         int discountPercent = Integer.parseInt(scan.nextLine());
  10.  
  11.         double umbrellaPrice = (towelPrice * 2) / 3;
  12.         double flipFlopPrice = umbrellaPrice * 0.75;
  13.         double bagPrice = (flipFlopPrice + towelPrice) / 3;
  14.  
  15.         double finalPrice = (towelPrice + umbrellaPrice + flipFlopPrice + bagPrice) * (1 - discountPercent / 100.0);
  16.         double difference = Math.abs(finalPrice - budget);
  17.  
  18.         if (finalPrice <= budget) {
  19.             System.out.println(String.format("Annie's sum is %.2f lv. She has %.2f lv. left.", finalPrice, difference));
  20.         } else {
  21.             System.out.println(String.format("Annie's sum is %.2f lv. She needs %.2f lv. more.", finalPrice, difference));
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement