I wonder if someone can help with this;
private static double EndProgram;
static void Main(string[] args)
{
int firstNumber;
int secondNumber;
string operand = string.Empty;
float result;
string text1;
do
Console.WriteLine("Please choose your option ");
Console.WriteLine("--------------------------------------------------------------------------------");
Console.WriteLine("1. Addition."
+ Environment.NewLine
+ "2. Substraction"
+ "3. Multiplication"
+ "4. Division"
+ "5. Modulus"
+ "6. End Program");
////enter first number ////
Console.Write("Please enter a number: ");
text1 = Console.ReadLine();
// if number not integer then fail ////
bool res = int.TryParse(text1, out firstNumber);
while (!res)
Console.WriteLine(" FAIL");
res = int.TryParse(text1, out firstNumber);
}
//// enter operand ////
while (operand == string.Empty || operand.Length > 1 || !(new char[] { '+', '-', '*', '/' }).Contains(char.Parse(operand)))
Console.Write("Please enter an operand (+, -, /, *): ");
operand = Console.ReadLine();
// enter second number //
Console.Write("Please enter the second number: ");
// if number not integer then fail //
bool eff = int.TryParse(text1, out secondNumber);
while (!eff)
eff = int.TryParse(text1, out secondNumber);
// Console.Write("\n\tYour Choice : ");
// operand = Console.ReadLine();
// Console.WriteLine("\n\tPlease enter two numbers");
//Console.Write("\n\tfirstNmber : ");
//firstNumber = int.Parse(Console.ReadLine());
// Console.Write("\n\tsecondNumber : ");
// secondNumber = int.Parse(Console.ReadLine());
switch (operation)
case 1: result = firstNumber + secondNumber;
break;
case 2: result = firstNumber - secondNumber;
case 3: result = firstNumber * secondNumber;
case 4: result = firstNumber / secondNumber;
if (secondNumber == 0)
Console.WriteLine("Divide By Zero Error");
return;
case 5: result = firstNumber % secondNumber;
default:
Console.WriteLine("Wrong Choice!!");
result = 0;
Console.WriteLine("{0} {1} {2} = {3}", firstNumber, operand, secondNumber, result);
/// converts numbers to string using operand and writes final line ///
Console.WriteLine(firstNumber.ToString() + " " + operand + " " + secondNumber.ToString() + " = "+ result.ToString());
Console.ReadLine();