Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _01BakingMasterclass
- {
- class Program
- {
- static void Main(string[] args)
- {
- double budget = double.Parse(Console.ReadLine());
- int students = int.Parse(Console.ReadLine());
- double priceFlourPkg = double.Parse(Console.ReadLine());
- double pricePerEgg = double.Parse(Console.ReadLine());
- double pricePerApron = double.Parse(Console.ReadLine());
- double priceEggsPerStudent = 10 * pricePerEgg;
- int flourPkgs = students;
- int freeFlourPkgs = 0;
- for (int i = 1; i <= flourPkgs; i++)
- {
- if (i % 5 == 0)
- {
- freeFlourPkgs++;
- }
- }
- int totalFlourPkgs = flourPkgs - freeFlourPkgs;
- double aprons = Math.Ceiling(1.2 * students);
- double totalPrice = (totalFlourPkgs * priceFlourPkg) + (priceEggsPerStudent * students) + (aprons * pricePerApron);
- if (totalPrice <= budget)
- {
- Console.WriteLine("Items purchased for {0:f2}$.", totalPrice);
- }
- else
- {
- Console.WriteLine("{0:f2}$ more needed.", totalPrice - budget);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment