Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package _02_ConditionalStatements;
- import java.util.Scanner;
- public class ToyShop {
- 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 teddiesCount = Integer.parseInt(scanner.nextLine());
- int minionsCount = Integer.parseInt(scanner.nextLine());
- int trucksCount = Integer.parseInt(scanner.nextLine());
- double totalSum = (2.60 * puzzleCount) + (3.0 * dollsCount) + (4.10 * teddiesCount)
- + (8.20 * minionsCount) + (2.0 * trucksCount);
- int totalCount = puzzleCount + dollsCount + teddiesCount + minionsCount + trucksCount;
- if(totalCount >= 50) {
- totalSum = totalSum - (totalSum * 0.25);
- }
- totalSum = totalSum - (totalSum * 0.10);
- double diff = Math.abs(totalSum - tripPrice);
- if(totalSum >= 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