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