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 trip = Double.parseDouble(scanner.nextLine());
- double puzzle = Double.parseDouble(scanner.nextLine());
- double dolls = Double.parseDouble(scanner.nextLine());
- double bear = Double.parseDouble(scanner.nextLine());
- double minion = Double.parseDouble(scanner.nextLine());
- double truck = Double.parseDouble(scanner.nextLine());
- double allpuzzle = puzzle * 2.6;
- double alldolls = dolls * 3;
- double allbear = bear * 4.1;
- double allminions = minion * 8.2;
- double alltruck = truck * 2;
- double toys = puzzle + dolls + bear + minion + truck;
- double total = allpuzzle + alldolls + allbear + allminions + alltruck;
- if (toys >= 50) {
- total = total - (total * 0.25);
- }
- double finalSum = (total - total * 0.1);
- if (finalSum >= trip) {
- System.out.printf("Yes! %.2f lv left.", finalSum - trip);
- } else {
- System.out.printf("Not enough money! %.2f lv needed.", trip - finalSum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement