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 priceOfTrip = Double.parseDouble(scan.nextLine());
- int puzzles = Integer.parseInt(scan.nextLine());
- int dolls = Integer.parseInt(scan.nextLine());
- int bears = Integer.parseInt(scan.nextLine());
- int minions = Integer.parseInt(scan.nextLine());
- int trucks = Integer.parseInt(scan.nextLine());
- double priceForOnePuzzle = 2.60;
- double priceForOneDoll = 3.00;
- double priceForOneBear = 4.10;
- double priceForOneMinion = 8.20;
- double priceForOneTruck = 2.00;
- double price = puzzles * priceForOnePuzzle + dolls * priceForOneDoll + bears * priceForOneBear + minions * priceForOneMinion + trucks * priceForOneTruck;
- int toys = puzzles + dolls + bears + minions + trucks;
- if(toys > 50){
- price = price * 0.75;
- }
- double pechalba = price * 0.9;
- if(pechalba > priceOfTrip){
- System.out.printf("Yes! %.2f lv left.", pechalba - priceOfTrip);
- }
- else{
- System.out.printf("Not enough money! %.2f lv needed.", priceOfTrip - pechalba);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement