using System;
namespace Calculator
{
class CalculateNumber
{
static void Main(string[] args)
{
int number1, number2;
char option, quit;
int result;
Console.WriteLine("Enter the first number");
number1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the second number");
number2 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("MAIN MENU");
Console.WriteLine("1. Addition");
Console.WriteLine("2. Substraction");
Console.WriteLine("3. Multiplication");
Console.WriteLine("4. Division");
Console.WriteLine("Enter the operation ypu want to program");
option = Convert.ToChar(Console.ReadLine());
quit = 'y';
while (quit == 'y' || quit == 'Y')
{
switch (option)
{
case '1':
result = number1 + number2;
Console.WriteLine("The result of addition is :{0}", result);
break;
case '2':
result = number1 - number2;
Console.WriteLine("The result of substraction is :{0}", result);
break;
case '3':
result = number1 * number2;
Console.WriteLine("The result of multiplication is :{0}", result);
break;
case '4':
result = number1 / number2;
Console.WriteLine("The result of division is :{0}", result);
break;
default:
Console.WriteLine("Invalid option");
break;
}
Console.Write("Do You want to continue (Y or N) :");
quit = Convert.ToChar(Console.ReadLine());
}
}
}
namespace Calculator
{
class CalculateNumber
{
static void Main(string[] args)
{
int number1, number2;
char option, quit;
int result;
Console.WriteLine("Enter the first number");
number1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the second number");
number2 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("MAIN MENU");
Console.WriteLine("1. Addition");
Console.WriteLine("2. Substraction");
Console.WriteLine("3. Multiplication");
Console.WriteLine("4. Division");
Console.WriteLine("Enter the operation ypu want to program");
option = Convert.ToChar(Console.ReadLine());
quit = 'y';
while (quit == 'y' || quit == 'Y')
{
switch (option)
{
case '1':
result = number1 + number2;
Console.WriteLine("The result of addition is :{0}", result);
break;
case '2':
result = number1 - number2;
Console.WriteLine("The result of substraction is :{0}", result);
break;
case '3':
result = number1 * number2;
Console.WriteLine("The result of multiplication is :{0}", result);
break;
case '4':
result = number1 / number2;
Console.WriteLine("The result of division is :{0}", result);
break;
default:
Console.WriteLine("Invalid option");
break;
}
Console.Write("Do You want to continue (Y or N) :");
quit = Convert.ToChar(Console.ReadLine());
}
}
}
Comments
Post a Comment