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 excursionPrice = Double.parseDouble(scanner.nextLine());
- int numberOfPuzzles = Integer.parseInt(scanner.nextLine());
- int numberOfDolls = Integer.parseInt(scanner.nextLine());
- int numberOfBears = Integer.parseInt(scanner.nextLine());
- int numberOfMinions = Integer.parseInt(scanner.nextLine());
- int numberOfTrucks = Integer.parseInt(scanner.nextLine());
- int totalToys = numberOfBears + numberOfDolls + numberOfMinions + numberOfPuzzles + numberOfTrucks;
- double puzzleProfit = numberOfPuzzles * 2.6;
- double dollsProfit = numberOfDolls * 3;
- double bearsProfit = numberOfBears * 4.1;
- double minionsProfit = numberOfMinions * 8.2;
- double trucksProfit = numberOfTrucks * 2;
- double totalProfit = puzzleProfit + dollsProfit + bearsProfit + minionsProfit + trucksProfit;
- if (totalToys >= 50) {
- double discount = totalProfit * 0.25;
- totalProfit = totalProfit - discount;
- }
- totalProfit = totalProfit * 0.9;
- totalProfit = totalProfit - excursionPrice;
- if (totalProfit >= 0){
- System.out.printf("Yes! %.2f lv left.", totalProfit);
- } else {
- System.out.printf("Not enough money! %.2f lv needed.", Math.abs(totalProfit));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement