Advertisement
lexxandras

Untitled

Mar 26th, 2020
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.63 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ToyShop {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.  
  7.         double priceTrip = Double.parseDouble(scan.nextLine());
  8.         int puzzle = Integer.parseInt(scan.nextLine());
  9.         int talkingDolls = Integer.parseInt(scan.nextLine());
  10.         int teddyBears = Integer.parseInt(scan.nextLine());
  11.         int minions = Integer.parseInt(scan.nextLine());
  12.         int trucks = Integer.parseInt(scan.nextLine());
  13.  
  14.         double puzzlePrice = 2.60;
  15.         int dollPrice = 3;
  16.         double teddyBearPrice = 4.10;
  17.         double minionsPrice = 8.20;
  18.         int truckPrice = 2;
  19.  
  20.         double sum =
  21.                 puzzlePrice * puzzle + talkingDolls * dollPrice + teddyBearPrice * teddyBears + minions * minionsPrice + truckPrice * trucks;
  22.         int toys = puzzle + teddyBears + minions + talkingDolls + trucks;
  23.  
  24.         if (toys >= 50){
  25.             double discount = sum * 0.25;
  26.      
  27.              sum = sum - discount;
  28.         }
  29.  
  30.         double rent = sum * 0.1;
  31.         double priceAfterRent = sum - rent;
  32.        
  33.  
  34.         if (priceAfterRent > priceTrip){
  35.             double totalPrice = priceAfterRent -priceTrip;
  36.             System.out.print("Yes! ");
  37.             System.out.printf("%.2f", totalPrice);
  38.             System.out.print( " lv left.");
  39.         }
  40.         else if (priceAfterRent < priceTrip){
  41.             double totalPrice = priceTrip - priceAfterRent;
  42.             System.out.print("Not enough money! ");
  43.             System.out.printf("%.2f",totalPrice);
  44.             System.out.print(" lv needed.");
  45.         }
  46.     }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement