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 scanner = new Scanner(System.in);
- double tripPrice = Double.parseDouble(scanner.nextLine());
- int countOfPuzzles = Integer.parseInt(scanner.nextLine());
- int countOfDolls = Integer.parseInt(scanner.nextLine());
- int countOfBears = Integer.parseInt(scanner.nextLine());
- int countOfMinions = Integer.parseInt(scanner.nextLine());
- int countOfTrucks = Integer.parseInt(scanner.nextLine());
- int countOfToys = countOfBears + countOfDolls + countOfMinions + countOfPuzzles + countOfTrucks;
- double prices = countOfPuzzles * 2.60 + countOfDolls * 3 + countOfMinions * 8.20 + countOfTrucks * 2 + countOfBears * 4.10;
- double priceTotal = 0.00;
- double rent = 0.10;
- double priceFinal = 0.00;
- if (countOfToys > 50) {
- priceTotal = prices * 0.75;
- priceFinal = priceTotal -(priceTotal*rent);
- double moneyLeft = Math.abs(priceFinal - tripPrice);
- if (priceFinal >= tripPrice) {
- System.out.printf("Yes! %.2f lv left.", moneyLeft);
- } else {
- System.out.printf("Not enough money! %.2f lv needed.", moneyLeft);
- }
- } else if (countOfToys < 50) {
- priceTotal = prices;
- priceFinal = priceTotal- (priceTotal*rent);
- double moneyLeft = Math.abs(priceFinal - tripPrice);
- if (priceFinal >= tripPrice) {
- System.out.printf("Yes! %.2f lv left.", moneyLeft);
- } else {
- System.out.printf("Not enough money! %.2f lv needed.", moneyLeft);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement