Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading;
- using System.Threading.Tasks;
- namespace Test
- {
- class Program
- {
- public static Int32 Height;
- public static Int32 Base;
- public static Int32 Result;
- static void Main()
- {
- string UserInput = ""; //This string will be used for information inputted by a user.
- Console.Clear(); //Clears the console
- Console.WriteLine("Input The Height:"); //Writes in the console.
- UserInput = Console.ReadLine(); //Updates the user input string with what the user put into the console.
- if (Regex.IsMatch(UserInput, @"^[0-9]*$")) //Uses Regex to check if the user input is a number.
- {
- Height = Convert .ToInt32(UserInput); //Converts the user input into a integer.
- Console.WriteLine("Input The Base:"); //Writes in the console.
- UserInput = Console.ReadLine(); //Updates the user input string with what the user put into the console.
- if (Regex.IsMatch(UserInput, @"^[0-9]*$")) //Uses Regex to check if the user input is a number.
- {
- Base = Convert.ToInt32(UserInput); //Converts the user input into a integer.
- DoMath(); //Goto DoMath.
- }
- else
- {
- Console.WriteLine("Please enter a number."); //Writes in the console.
- Thread.Sleep(1000);
- Main(); //Goto Main.
- }
- }
- else
- {
- Console.WriteLine("Please enter a number."); //Writes in the console.
- Thread.Sleep(1000);
- Main(); //Goto Main.
- }
- }
- static void DoMath()
- {
- Console.WriteLine("Calculating...");
- Thread.Sleep(100);
- Console.Clear();
- /*Result = Height * Base / 2; //Does the maths
- bool calculating = true;
- do
- {
- Console.WriteLine("Calculating."); //Writes in the console.
- Thread.Sleep(1);
- Console.Clear();
- Console.WriteLine("Calculating..");
- Thread.Sleep(1);
- Console.Clear();
- Console.WriteLine("Calculating...");
- Thread.Sleep(1);
- Console.Clear();
- } while (calculating is true);
- */
- Result = Height * Base / 2; //Does the maths
- Console.WriteLine("Your result is: " + Result); //Writes in the console.
- Console.ReadLine(); //Waits
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement