deyanivanov966

07. Toy Shop

Aug 23rd, 2020 (edited)
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.39 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.  
  7.         double tripPrice = Double.parseDouble(scanner.nextLine());
  8.         int puzzles = Integer.parseInt(scanner.nextLine());
  9.         int barbieDolls = Integer.parseInt(scanner.nextLine());
  10.         int bears = Integer.parseInt(scanner.nextLine());
  11.         int minions = Integer.parseInt(scanner.nextLine());
  12.         int trucks = Integer.parseInt(scanner.nextLine());
  13.         double totalPuzzlesPrice= 2.60* puzzles;
  14.         double totalBarbiePrice = 3.0*barbieDolls ;
  15.         double totalBearsPrice = 4.10*bears;
  16.         double totalMinionsPrice = 8.20*minions;
  17.         double totalTrucksPrice =  2.0*trucks;
  18.         double total= totalPuzzlesPrice+totalBarbiePrice+totalBearsPrice+totalMinionsPrice+totalTrucksPrice;
  19.         double counter=puzzles+barbieDolls+bears+minions+trucks;
  20.  
  21.         if (counter>=50)
  22.         {
  23.             total=total*0.75;
  24.  
  25.         }
  26.         double finalProfit=total*0.9;
  27.         if (finalProfit>=tripPrice)
  28.         {
  29.             double diff=finalProfit-tripPrice;
  30.             System.out.printf("Yes! %.2f lv left.",diff);
  31.         }
  32.         else
  33.         {
  34.             double difference=tripPrice-finalProfit;
  35.             System.out.printf("Not enough money! %.2f lv needed.",difference);
  36.         }
  37.  
  38.  
  39.     }
  40. }
Add Comment
Please, Sign In to add comment