Advertisement
bubeto1979

Untitled

May 11th, 2017
451
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.73 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. /**
  5.  * Created by Bubeto on 5/11/2017.
  6.  */
  7. public class ToyShops1 {
  8.     public static void main(String[] args) {
  9.         Scanner scanner = new Scanner(System.in);
  10.  
  11.         double puzzle = 2.6;
  12.         double doll = 3;
  13.         double bear = 4.1;
  14.         double minion = 8.2;
  15.         double truck = 2;
  16.  
  17.         double priceTour = Double.parseDouble(scanner.nextLine());
  18.         int countPuzzle = Integer.parseInt(scanner.nextLine());
  19.         int countDoll = Integer.parseInt(scanner.nextLine());
  20.         int countBear = Integer.parseInt(scanner.nextLine());
  21.         int countMinion = Integer.parseInt(scanner.nextLine());
  22.         int countTruck = Integer.parseInt(scanner.nextLine());
  23.  
  24.         int countToys = countPuzzle + countDoll + countBear + countMinion + countTruck;
  25.         double priceToys = puzzle*countPuzzle + doll*countDoll + bear*countBear + minion*countMinion + truck*countTruck;
  26.         double realPrice = 0;
  27.  
  28.         if (countToys >= 50){
  29.             priceToys = priceToys - 0.25*priceToys;
  30.             realPrice = priceToys - 0.1*priceToys;
  31.              if(priceTour <= realPrice){
  32.                  System.out.printf("Yes! %.2f lv left.", realPrice - priceTour);
  33.  
  34.              }
  35.              else {
  36.                  System.out.printf("Not enough money! %.2f lv needed.", priceTour - realPrice);
  37.              }
  38.         }
  39.  
  40.          else {
  41.             realPrice = priceToys - 0.1*priceToys;
  42.             if(priceTour <= realPrice){
  43.                 System.out.printf("Yes! %.2f lv left.", realPrice - priceTour);
  44.  
  45.             }
  46.             else {
  47.                 System.out.printf("Not enough money! %.2f lv needed.", priceTour - realPrice);
  48.             }
  49.  
  50.         }
  51.  
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement