Advertisement
veronikaaa86

Toy Shop

Oct 1st, 2017
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.26 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P02_ToyShop {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         double holidayPrice = Double.parseDouble(scanner.nextLine());
  8.         int countPuzzle = Integer.parseInt(scanner.nextLine());
  9.         int countDolls = Integer.parseInt(scanner.nextLine());
  10.         int countBears = Integer.parseInt(scanner.nextLine());
  11.         int countMinions = Integer.parseInt(scanner.nextLine());
  12.         int countTrucks = Integer.parseInt(scanner.nextLine());
  13.  
  14.         double sumBgnAll = (countPuzzle*2.6)+(countDolls*3)+(countBears*4.10)+(countMinions*8.2)+(countTrucks*2);
  15.         double sumToys = countPuzzle+countDolls+countBears+countMinions+countTrucks;
  16.  
  17.         double discount = 0.0;
  18.         double tax = 0.0;
  19.  
  20.         if (sumToys>=50) {
  21.             discount = sumBgnAll*0.25;
  22.             sumBgnAll=sumBgnAll-discount;
  23.         }
  24.  
  25.         tax=sumBgnAll*0.10;
  26.         sumBgnAll=sumBgnAll-tax;
  27.  
  28.         if (sumBgnAll>=holidayPrice) {
  29.             System.out.printf("Yes! %.2f lv left.", sumBgnAll-holidayPrice);
  30.         }else {
  31.             double sumNeeded=holidayPrice-sumBgnAll;
  32.             System.out.printf("Not enough money! %.2f lv needed.", sumNeeded);
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement