Advertisement
DeeAG

ToyShop

Oct 14th, 2020 (edited)
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.86 KB | None | 0 0
  1. namespace ToyShop
  2. {
  3. using System;
  4.     class StartUp
  5.     {
  6.         static void Main(string[] args)
  7.         {
  8.             const double puzzlesPrice = 2.60;
  9.             const double talkingDollPrice = 3.00;
  10.             const double teddyBearPrice = 4.10;
  11.             const double minionPrice = 8.20;
  12.             const double truckPrice = 2.00;
  13.             double priceOfTheExcursion = double.Parse(Console.ReadLine());
  14.             int numberOfPuzzles = int.Parse(Console.ReadLine());
  15.             int numberOfTalkingDolls = int.Parse(Console.ReadLine());
  16.             int numberOfTeddyBears = int.Parse(Console.ReadLine());
  17.             int numberOfMinions = int.Parse(Console.ReadLine());
  18.             int numberOfTrucks = int.Parse(Console.ReadLine());
  19.             int totalToys = numberOfPuzzles + numberOfTalkingDolls + numberOfTeddyBears + numberOfMinions + numberOfTrucks;
  20.             double totalPrice = numberOfPuzzles * puzzlesPrice + numberOfTalkingDolls * talkingDollPrice + numberOfTeddyBears * teddyBearPrice + numberOfMinions * minionPrice + numberOfTrucks * truckPrice;
  21.             double earnedMoney = 0;
  22.             if (totalToys >= 50)
  23.             {
  24.                 earnedMoney = totalPrice * 0.75;
  25.             }
  26.             else
  27.             {
  28.                 earnedMoney = totalPrice;
  29.             }            
  30.             double earnedMoneyAfterRent = earnedMoney * 0.90;
  31.             if (earnedMoneyAfterRent >= priceOfTheExcursion)
  32.             {
  33.                 double moneyLeft = earnedMoneyAfterRent - priceOfTheExcursion;
  34.                 Console.WriteLine($"Yes! {moneyLeft:f2} lv left.");
  35.             }
  36.             else
  37.             {
  38.                 double moneyNeeded = priceOfTheExcursion - earnedMoneyAfterRent;
  39.                 Console.WriteLine($"Not enough money! {moneyNeeded:f2} lv needed.");
  40.             }            
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement