Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace P04_Cake
- {
- class Program
- {
- static void Main(string[] args)
- {
- double lenght = double.Parse(Console.ReadLine());
- double width = double.Parse(Console.ReadLine());
- double cake = lenght * width;
- double needed = 0;
- while (true)
- {
- string current = Console.ReadLine();
- if (current == "STOP")
- {
- Environment.Exit(0);
- }
- double pieces = double.Parse(Console.ReadLine());
- if (cake >= pieces)
- {
- cake -= pieces;
- if (cake == 0)
- {
- Console.WriteLine(cake);
- Environment.Exit(0);
- }
- }
- if (pieces > cake)
- {
- needed = pieces - cake;
- break;
- }
- }
- Console.WriteLine($"No more cake left! You need {needed} pieces more.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement