Advertisement
NelIfandieva

ConditionalsExercise_Problem04_ToyShop

Mar 12th, 2022
986
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.49 KB | None | 0 0
  1. using System;
  2.  
  3. namespace P04_ToyShopProject
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             double puzzelsPrice = 2.60;
  10.             double barbiesPrice = 3.00;
  11.             double bearsPrice = 4.10;
  12.             double minersPrice = 8.20;
  13.             double trucksPrice = 2.00;
  14.  
  15.             double priceForVacantion = double.Parse(Console.ReadLine());
  16.             double numberOfPuzzels = double.Parse(Console.ReadLine());
  17.             double numberOfBarbies = int.Parse(Console.ReadLine());
  18.             double numberOfBears = double.Parse(Console.ReadLine());
  19.             double numberOfMiners = double.Parse(Console.ReadLine());
  20.             double numberOfTrucks = double.Parse(Console.ReadLine());
  21.  
  22.             double puzzelTotalPrice = numberOfPuzzels * puzzelsPrice;
  23.             double barbiesTotalPrice = numberOfBarbies * barbiesPrice;
  24.             double bearsTotalPrice = numberOfBears * bearsPrice;
  25.             double minersTotalPrice = numberOfMiners * minersPrice;
  26.             double truckTotalPrice = numberOfTrucks * trucksPrice;
  27.  
  28.             double totalToys = numberOfPuzzels +
  29.                                numberOfBarbies +
  30.                                numberOfBears +
  31.                                numberOfMiners +
  32.                                numberOfTrucks;
  33.  
  34.             double commonToAllPrice = puzzelTotalPrice +
  35.                                       barbiesTotalPrice +
  36.                                       bearsTotalPrice +
  37.                                       minersTotalPrice +
  38.                                       truckTotalPrice;
  39.  
  40.             if(totalToys >= 50)
  41.             {
  42.                 double discount = 0.25 * commonToAllPrice; // паричната равностойност на отстъпката
  43.                 commonToAllPrice = commonToAllPrice - discount; // прави отстъпката
  44.             }
  45.  
  46.             commonToAllPrice = commonToAllPrice - (commonToAllPrice * 0.1); // плаща наема
  47.  
  48.             if(commonToAllPrice >= priceForVacantion)
  49.             {
  50.                 double remainingMoney = commonToAllPrice - priceForVacantion;
  51.                 Console.WriteLine("Yes! " + ($"{remainingMoney:f2}") +" lv left.");
  52.             }
  53.             else
  54.             {
  55.                 double insufficientMoney = priceForVacantion - commonToAllPrice;
  56.                 Console.WriteLine("Not enough money! " + ($"{insufficientMoney:f2}") + " lv needed.");
  57.             }
  58.         }
  59.     }
  60. }
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement