Advertisement
Dianov

Conditional Statements - Lab (07. Toy Shop (not included in final score))

Oct 16th, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.35 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ToyShop
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             double vacationPrice = double.Parse(Console.ReadLine());
  14.             int puzzles = int.Parse(Console.ReadLine());
  15.             int dolls = int.Parse(Console.ReadLine());
  16.             int bears = int.Parse(Console.ReadLine());
  17.             int minions = int.Parse(Console.ReadLine());
  18.             int trucks = int.Parse(Console.ReadLine());
  19.  
  20.             double moneyWon = (puzzles * 2.60) + (dolls * 3) + (bears * 4.10) + (minions * 8.20) + (trucks * 2);
  21.             int toysCount = puzzles + dolls + bears + minions + trucks;
  22.             double finalMoneyLeft;
  23.             if (toysCount >= 50)
  24.             {
  25.                 double discount = moneyWon * 0.25;
  26.                 double moneyAfterDiscount = moneyWon - discount;
  27.                 double rent = moneyAfterDiscount * 0.10;
  28.                 finalMoneyLeft = moneyAfterDiscount - rent;
  29.                
  30.                 if (finalMoneyLeft >= vacationPrice)
  31.                 {
  32.                     double moneyForVacation = finalMoneyLeft - vacationPrice;
  33.                    
  34.                     Console.WriteLine("Yes! {0:F2} lv left.", moneyForVacation);
  35.                 }
  36.                 else
  37.                 {
  38.                     double neededMoney = vacationPrice - finalMoneyLeft;
  39.                    
  40.                     Console.WriteLine("Not enough money! {0:F2} lv needed.", neededMoney);
  41.                 }
  42.  
  43.             }
  44.             else // toysCount < 50 =>> no discount in this case.
  45.             {
  46.                 double rent = moneyWon * 0.10;
  47.                 finalMoneyLeft = moneyWon - rent;
  48.                
  49.                 if (finalMoneyLeft >= vacationPrice)
  50.                 {
  51.                     double moneyForVacation = finalMoneyLeft - vacationPrice;
  52.                    
  53.                     Console.WriteLine("Yes! {0:F2} lv left.", moneyForVacation);
  54.                 }
  55.                 else
  56.                 {
  57.                     double neededMoney = vacationPrice - finalMoneyLeft;
  58.                    
  59.                     Console.WriteLine("Not enough money! {0:F2} lv needed.", neededMoney);
  60.                 }
  61.             }
  62.         }
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement