Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.40 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ToyShop {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         double tripPrice = Double.parseDouble(scanner.nextLine());
  7.         int puzzles = Integer.parseInt(scanner.nextLine());
  8.         int doll = Integer.parseInt(scanner.nextLine());
  9.         int bear = Integer.parseInt(scanner.nextLine());
  10.         int minions = Integer.parseInt(scanner.nextLine());
  11.         int trucks = Integer.parseInt(scanner.nextLine());
  12.  
  13.         double puzzlesPrice = puzzles * 2.60;
  14.         double dollPrice = doll * 3;
  15.         double bearPrice = bear * 4.10;
  16.         double trucksPrice = trucks * 2;
  17.         double minionsPrice = minions * 8.20;
  18.         double price = puzzlesPrice + dollPrice + bearPrice + minionsPrice + trucksPrice;
  19.  
  20.         double finalPrice = 0;
  21.  
  22.  
  23.         if (puzzles + doll + bear + minions + trucks >= 50) {
  24.             double totalPrice = price - (price * 0.25);
  25.             finalPrice = totalPrice - (totalPrice * 0.1);
  26.         } else  {
  27.             finalPrice = price - (price * 0.1);
  28.         }
  29.         if(finalPrice >= tripPrice){
  30.             double left = finalPrice - tripPrice;
  31.             System.out.printf("Yes! %.2f lv left.",left);
  32.         } else {
  33.             double need = tripPrice - finalPrice;
  34.             System.out.printf("Not enough money! %.2f lv needed.",need);
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement