Dianov

Basic Syntax, Conditional Statements and Loops - Exercise (09. Padawan Equipment)

Mar 26th, 2021 (edited)
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 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.             decimal ivanChosMoney = decimal.Parse(Console.ReadLine());
  14.             int studentsCount = int.Parse(Console.ReadLine());
  15.             decimal lightsabersPrice = decimal.Parse(Console.ReadLine());
  16.             decimal robesPrice = decimal.Parse(Console.ReadLine());
  17.             decimal beltsPrice = decimal.Parse(Console.ReadLine());
  18.  
  19.             int freeBelts = studentsCount / 6;
  20.             decimal moneyNeeded = (lightsabersPrice * (Math.Ceiling(studentsCount + studentsCount * 0.1m))) + (robesPrice * studentsCount) + beltsPrice * (studentsCount - freeBelts);
  21.  
  22.             if (moneyNeeded <= ivanChosMoney)
  23.             {
  24.                 Console.WriteLine($"The money is enough - it would cost {moneyNeeded:F2}lv.");
  25.             }
  26.             else
  27.             {
  28.                 Console.WriteLine($"John will need {Math.Abs(ivanChosMoney - moneyNeeded):F2}lv more.");
  29.             }
  30.         }
  31.     }
  32. }
Add Comment
Please, Sign In to add comment