Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 2

using System;

class DiscountProgram
{
static void Main()
{
int num1, num2, code, sum, diff, prod;
double quotient;
Console.Write("Please enter the first number: ");
num1 = Convert.ToInt32(Console.ReadLine());
Console.Write("Please enter the second number: ");
num2 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("\n\nPlease make a selection");
Console.WriteLine("Press 1 ---> Sum");
Console.WriteLine("Press 2 ---> Difference");
Console.WriteLine("Press 3 ---> Product");
Console.WriteLine("Press 4 ---> Quotient");
code = Convert.ToInt16(Console.ReadLine());
Console.WriteLine("The two number entered were {0} and {1}, the code enter {2}. ",
num1, num2, code);
switch (code)
{
case 1:
sum = num1 + num2;
Console.Write("The sum is:"+sum);
break;
case 2:

diff = num1 - num2;


Console.Write("The Difference is:" + diff);
break;
case 3:
prod = num1 * num2;
Console.Write("The Product is:" + prod);
break;
case 4:
if (num2 != 0)
{
quotient = num1 / num2;
Console.Write("The Quotient is:" + quotient);
}
break;
default:
Console.WriteLine("Error Code entered");
break;
}
Console.ReadKey();
}
}

You might also like