Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ConditionalStatements;
- import java.util.Scanner;
- public class P06ToyShop {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double tripPrice = Double.parseDouble(scanner.nextLine());
- int puzzleCount = Integer.parseInt(scanner.nextLine());
- int dollsCount = Integer.parseInt(scanner.nextLine());
- int teddyCount = Integer.parseInt(scanner.nextLine());
- int minionsCount = Integer.parseInt(scanner.nextLine());
- int trucksCount = Integer.parseInt(scanner.nextLine());
- // • Пъзел - 2.60 лв.
- // • Говореща кукла - 3 лв.
- // • Плюшено мече - 4.10 лв.
- // • Миньон - 8.20 лв.
- // • Камионче - 2 лв.
- double sum = (puzzleCount * 2.60) + (dollsCount * 3) + (teddyCount * 4.10) + (minionsCount * 8.20) + (trucksCount * 2.00);
- int countAllToys = puzzleCount + dollsCount + teddyCount + minionsCount + trucksCount;
- if (countAllToys >= 50) {
- sum = sum * 0.75;
- }
- sum = sum * 0.90;
- double diff = Math.abs(sum - tripPrice);
- if (sum >= tripPrice) {
- System.out.printf("Yes! %.2f lv left.", diff);
- } else {
- System.out.printf("Not enough money! %.2f lv needed.", diff);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement