desito07

Guinea Pig

Feb 9th, 2023
839
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _04_Mid_Exam_Tasks
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double food = double.Parse(Console.ReadLine());
  10.             double hay = double.Parse(Console.ReadLine());
  11.             double cover = double.Parse(Console.ReadLine());
  12.             double weight = double.Parse(Console.ReadLine());
  13.  
  14.             int days = 30;
  15.  
  16.             for (int i = 1; i <= days; i++)
  17.             {
  18.  
  19.                 food -= 0.3;
  20.  
  21.                 if (i % 2 == 0)
  22.                 {
  23.                     hay -= food * 0.05;
  24.                 }
  25.  
  26.                 if (i % 3 == 0)
  27.                 {
  28.                     cover -= weight / 3;
  29.                 }
  30.             }
  31.  
  32.             if (food <= 0 || hay <= 0 || cover <= 0)
  33.             {
  34.                 Console.WriteLine($"Merry must go to the pet store!");
  35.             }
  36.             else
  37.             {
  38.                 Console.WriteLine($"Everything is fine! Puppy is happy! Food: {food:f2}, Hay: {hay:f2}, Cover: {cover:f2}.");
  39.             }
  40.         }
  41.     }
  42. }
  43.  
  44.  
Advertisement
Add Comment
Please, Sign In to add comment