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