Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.80 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using System.Threading;
  7. using System.Threading.Tasks;
  8.  
  9. namespace Test
  10. {
  11.     class Program
  12.     {
  13.         public static Int32 Height;
  14.         public static Int32 Base;
  15.         public static Int32 Result;
  16.  
  17.         static void Main()
  18.         {
  19.             string UserInput = ""; //This string will be used for information inputted by a user.
  20.  
  21.             Console.Clear(); //Clears the console
  22.             Console.WriteLine("Input The Height:"); //Writes in the console.
  23.             UserInput = Console.ReadLine(); //Updates the user input string with what the user put into the console.
  24.             if (Regex.IsMatch(UserInput, @"^[0-9]*$")) //Uses Regex to check if the user input is a number.
  25.             {
  26.                 Height = Convert .ToInt32(UserInput); //Converts the user input into a integer.
  27.                 Console.WriteLine("Input The Base:"); //Writes in the console.
  28.                 UserInput = Console.ReadLine(); //Updates the user input string with what the user put into the console.
  29.                 if (Regex.IsMatch(UserInput, @"^[0-9]*$")) //Uses Regex to check if the user input is a number.
  30.                 {
  31.                     Base = Convert.ToInt32(UserInput); //Converts the user input into a integer.
  32.                     DoMath(); //Goto DoMath.
  33.                 }
  34.                 else
  35.                 {
  36.                     Console.WriteLine("Please enter a number."); //Writes in the console.
  37.                     Thread.Sleep(1000);
  38.                     Main(); //Goto Main.
  39.                 }
  40.             }
  41.             else
  42.             {
  43.                 Console.WriteLine("Please enter a number."); //Writes in the console.
  44.                 Thread.Sleep(1000);
  45.                 Main(); //Goto Main.
  46.             }
  47.         }
  48.  
  49.         static void DoMath()
  50.         {
  51.             Console.WriteLine("Calculating...");
  52.             Thread.Sleep(100);
  53.             Console.Clear();
  54.  
  55.             /*Result = Height * Base / 2; //Does the maths
  56.             bool calculating = true;
  57.             do
  58.             {
  59.                 Console.WriteLine("Calculating."); //Writes in the console.
  60.                 Thread.Sleep(1);
  61.                 Console.Clear();
  62.                 Console.WriteLine("Calculating..");
  63.                 Thread.Sleep(1);
  64.                 Console.Clear();
  65.                 Console.WriteLine("Calculating...");
  66.                 Thread.Sleep(1);
  67.                 Console.Clear();
  68.             } while (calculating is true);
  69.             */
  70.             Result = Height * Base / 2; //Does the maths
  71.  
  72.             Console.WriteLine("Your result is: " + Result); //Writes in the console.
  73.             Console.ReadLine(); //Waits
  74.         }
  75.  
  76.        
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement