Advertisement
Guest User

Untitled

a guest
Jun 15th, 2022
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.57 KB | None | 0 0
  1. using System;
  2. using System.Linq.Expressions;
  3.  
  4. namespace Add_Bags
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             int hight = int.Parse(Console.ReadLine());
  11.             int length = int.Parse(Console.ReadLine());
  12.             int percentage = int.Parse(Console.ReadLine());
  13.  
  14.             const int walls = 4;
  15.             double totalCover = 0;
  16.             double count = 0;
  17.            
  18.             totalCover = hight * length * walls;
  19.             totalCover -= totalCover * (percentage * 0.01);
  20.            
  21.             while (true)
  22.             {
  23.                 string line = Console.ReadLine();
  24.  
  25.                 if (line == "Tired!")
  26.                 {
  27.                     Console.WriteLine($"{totalCover} quadratic m left.");
  28.                     return;   //за да приключи
  29.                 }
  30.                 count = int.Parse(line);
  31.  
  32.                 totalCover -= count;
  33.  
  34.                 if (totalCover == 0) //ако е всичко е боядисано и няма останало
  35.                 {
  36.                     Console.WriteLine($"All walls are painted! Great job, Pesho!");
  37.                     return; //за да приключи
  38.                 }
  39.                 else if(totalCover < 0) //ако е всичко е боядисано и има останало
  40.                 {
  41.                     Console.WriteLine($"All walls are painted and you have {Math.Abs(totalCover)} l paint left!");
  42.                     return; //за да приключи
  43.                 }
  44.             }
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement