Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _06Cake
- {
- class Cake
- {
- static void Main(string[] args)
- {
- double cakeWidth = double.Parse(Console.ReadLine());
- double cakeLength = double.Parse(Console.ReadLine());
- string command = Console.ReadLine();
- command = command.ToUpper();
- double cakePieces = (cakeWidth * cakeLength);
- int eatenPieces = 0;
- while (command != "STOP")
- {
- eatenPieces = int.Parse(command);
- if (cakePieces >= eatenPieces)
- {
- cakePieces -= eatenPieces;
- }
- else
- {
- cakePieces = Math.Abs(cakePieces - eatenPieces);
- Console.WriteLine($"No more cake left! You need {cakePieces} pieces more.");
- break;
- }
- command = Console.ReadLine();
- if (command == "STOP")
- {
- Console.WriteLine($"{cakePieces} pieces are left.");
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement