Advertisement
Guest User

Padawan Equipment

a guest
Dec 17th, 2018
578
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.48 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 PadawanEquipment
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             double allMoney = double.Parse(Console.ReadLine());
  14.             int studentsCount = int.Parse(Console.ReadLine());
  15.             double lightsabersPrice = double.Parse(Console.ReadLine());
  16.             double robesPrice = double.Parse(Console.ReadLine());
  17.             double beltsPrice = double.Parse(Console.ReadLine());
  18.  
  19.             //totalprice = studentsCount * (light + robe + belt)
  20.  
  21.             double lightsabersTotal = (studentsCount + Math.Ceiling(studentsCount * 0.1)) * lightsabersPrice;
  22.             double robesTotal = studentsCount * robesPrice;
  23.             double beltsTotal = 0;
  24.             if (studentsCount >= 10)
  25.             {
  26.                 beltsTotal = (studentsCount - studentsCount / 6) * beltsPrice;
  27.             }
  28.             else
  29.             {
  30.                 beltsTotal = studentsCount * beltsPrice;
  31.             }
  32.  
  33.             double totalPrice = beltsTotal + robesTotal + lightsabersTotal;
  34.  
  35.             if (allMoney - totalPrice >= 0)
  36.             {
  37.                 Console.WriteLine($"The money is enough - it would cost {totalPrice:f2}lv.");
  38.             }
  39.             else
  40.             {
  41.                 Console.WriteLine($"Ivan Cho will need {(totalPrice - allMoney):f2}lv more.");
  42.             }
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement