Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ToyShop {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- double vacationPrice = Double.parseDouble(scan.nextLine());
- int puzzles = Integer.parseInt(scan.nextLine());
- int dogs = Integer.parseInt(scan.nextLine());
- int bears = Integer.parseInt(scan.nextLine());
- int minions = Integer.parseInt(scan.nextLine());
- int trucks = Integer.parseInt(scan.nextLine());
- double puzzlesPrice = puzzles * 2.6;
- int dogsPrice = dogs * 3;
- double bearsPrice = bears * 4.10;
- double minionsPrice = minions * 8.20;
- int trucksPrice = trucks * 2;
- double totalIncomeWithoutRent = (puzzlesPrice + dogsPrice + bearsPrice + minionsPrice + trucksPrice) * 0.90;
- int totalToys = puzzles + dogs + bears + minions + trucks;
- if (totalToys >= 50) {
- totalIncomeWithoutRent *= 0.75;
- }
- if (totalIncomeWithoutRent < vacationPrice) {
- double moneyNeeded = vacationPrice - totalIncomeWithoutRent;
- System.out.printf("Not enough money! %.2f lv needed.", moneyNeeded);
- } else {
- double moneyNeeded = totalIncomeWithoutRent - vacationPrice;
- System.out.printf("Yes! %.2f lv left.", moneyNeeded);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement