Advertisement
PIBogdanov

04. Toy Shop

Jan 15th, 2023
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.82 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _04.ToyShop
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double puzzle = 2.6;
  10.             double talkingDoll = 3.0;
  11.             double toyBear = 4.1;
  12.             double minion = 8.2;
  13.             double toyTruck = 2.0;
  14.             double trip = double.Parse(Console.ReadLine());
  15.             int numberOfPuzzles = int.Parse(Console.ReadLine());
  16.             int numberOfTalkingDolls = int.Parse(Console.ReadLine());
  17.             int numberOfToyBears = int.Parse(Console.ReadLine());
  18.             int numberOfMinions = int.Parse(Console.ReadLine());
  19.             int numberOfToyTrucks = int.Parse(Console.ReadLine());
  20.             int numberOfToys = numberOfPuzzles + numberOfTalkingDolls + numberOfToyBears + numberOfMinions + numberOfToyTrucks;
  21.             double puzzles = numberOfPuzzles * puzzle;
  22.             double talkingDolls = numberOfTalkingDolls * talkingDoll;
  23.             double toyBears = numberOfToyBears * toyBear;
  24.             double minions = numberOfMinions * minion;
  25.             double toyTrucks = numberOfToyTrucks * toyTruck;
  26.             double totalPrice = puzzles + talkingDolls + toyBears + minions + toyTrucks;
  27.             if (numberOfToys >= 50)
  28.             {
  29.                 double discount = 0.25 * totalPrice;
  30.                 totalPrice -= discount;
  31.             }
  32.             double rent = 0.1 * totalPrice;
  33.             totalPrice -= rent;
  34.             if (totalPrice >= trip)
  35.             {
  36.                 double profit = totalPrice - trip;
  37.                 Console.WriteLine($"Yes! {profit:f2} lv left.");
  38.             }
  39.             else
  40.             {
  41.                 double neededMoney = trip - totalPrice;
  42.                 Console.WriteLine($"Not enough money! {neededMoney:f2} lv needed.");
  43.             }
  44.         }
  45.     }
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement