Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.util.Scanner;
- public class ToyShop {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double priceOfV = Double.parseDouble(scanner.nextLine());
- int P = Integer.parseInt(scanner.nextLine());
- int dolls = Integer.parseInt(scanner.nextLine());
- int bears = Integer.parseInt(scanner.nextLine());
- int minions = Integer.parseInt(scanner.nextLine());
- int trucks = Integer.parseInt(scanner.nextLine());
- double price = ( P * 2.60 ) + ( dolls * 3 ) + ( bears * 4.10 ) + ( minions * 8.20 ) + ( trucks * 2 );
- int toys = P + dolls + bears + minions + trucks;
- if (toys >= 50) {price = price - (price * 0.25);}
- else price=price;
- double afterRent = price * 0.9;
- double left = afterRent - priceOfV;
- double need = priceOfV - afterRent;
- if (left > priceOfV) {System.out.printf("Yes! %.2f lv left.",left);}
- else if (priceOfV > need) {System.out.printf("Not enough money! %.2f lv needed.", need);}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment