Advertisement
sergezhu

Untitled

Mar 30th, 2023
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 KB | None | 0 0
  1. namespace ConsoleApp1;
  2.  
  3. using System.Text;
  4.  
  5. public class Task06
  6. {
  7.     public void Run()
  8.     {
  9.         Console.InputEncoding = Encoding.Unicode;
  10.         Console.OutputEncoding = Encoding.Unicode;
  11.  
  12.         Console.Write( "Input start gold value : " );
  13.         int goldValue = int.Parse( Console.ReadLine() );
  14.  
  15.         Console.Write( "Input start crystals value : " );
  16.         int crystalsValue = int.Parse( Console.ReadLine() );
  17.  
  18.         Console.Write( "Input crystals price : " );
  19.         int crystalPrice = int.Parse( Console.ReadLine() );
  20.  
  21.         bool canExit = false;
  22.  
  23.         while ( !canExit )
  24.         {
  25.             Console.WriteLine( $"Gold = {goldValue}, Cry = {crystalsValue}\n" );
  26.             Console.Write( "Buy crystals, input count : " );
  27.             int buyCrystalsCount = int.Parse( Console.ReadLine() );
  28.  
  29.             goldValue -= buyCrystalsCount * crystalPrice;
  30.             crystalsValue += buyCrystalsCount;
  31.  
  32.             Console.WriteLine( "Continue? Enter 'n' for exit" );
  33.             string continueAnswer = Console.ReadLine();
  34.             string exitAnswer = "n";
  35.  
  36.             canExit = string.Equals( continueAnswer, exitAnswer );
  37.         }
  38.     }
  39. }
  40.  
  41.  
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement