Advertisement
valkata

ToyShop

Sep 1st, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.32 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class toyShop {
  4.     public static void main(String[] args) {
  5.         Scanner input = new Scanner(System.in);
  6.         double tripP = Double.parseDouble(input.nextLine());
  7.         int puzzles = Integer.parseInt(input.nextLine());
  8.         int dolls = Integer.parseInt(input.nextLine());
  9.         int bears = Integer.parseInt(input.nextLine());
  10.         int minions = Integer.parseInt(input.nextLine());
  11.         int trucks = Integer.parseInt(input.nextLine());
  12.  
  13.         double puzzleP = 2.60;
  14.         double talkingDollP = 3.0;
  15.         double teddybear = 4.10;
  16.         double minion = 8.20;
  17.         double truck = 2.0;
  18.         double left = 0.0;
  19.  
  20.         double bill1 = (puzzleP * puzzles) + (talkingDollP * dolls) + (teddybear * bears) + (minion * minions) + (truck * trucks);
  21.         double totalToys = puzzles + dolls + bears + minions + trucks;
  22.         if(totalToys >= 50){
  23.             bill1 = bill1 - (bill1 * 0.25);
  24.         }
  25.         double rent  = bill1 * 0.1;
  26.         double finalIncome = bill1 - rent;
  27.         if(finalIncome >= tripP){
  28.             left = finalIncome - tripP;
  29.             System.out.printf("Yes! %.2f lv left.",left);
  30.         }else{
  31.             left = tripP - finalIncome;
  32.             System.out.printf("Not enough money! %.2f lv needed.",left);
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement