Console Application
In the previous blog we saw about sum of two number to see it again CLICK HERENow If you want to make console program for subtraction or multiplication then you have to only change the operator in the previous program.
Now We are going to see how we can make a calculator in Console.
Requirements:-1 User will provide the two numbers on which action to be performed.
2. After it User will select what action(Subtraction,addition,multiplication or division) user want to perform.
Sol:- Write this code .
Console.WriteLine("**** Enter the first number *****");
int x = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("**** Enter the second number *****");
int y = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("**** Enter 1 for addition *****");
Console.WriteLine("**** Enter 2 for subtration *****");
Console.WriteLine("**** Enter 3 for multification *****");
Console.WriteLine("**** Enter 4 for divition *****");
int z = Convert.ToInt32(Console.ReadLine());
switch (z)
{
case 1:
Console.WriteLine(x + y);
break;
case 2:
Console.WriteLine(x - y);
break;
case 3:
Console.WriteLine(x * y);
break;
case 4:
Console.WriteLine(x / y);
break;
}
Download Calculator
Great Work Bro !! :D
ReplyDelete