0

kindly if any one help me to create a calculator which is consaole based yet simple..
Regardz all...
Waitin for ur kind help..

2
Contributors
1
Reply
12
Views
7 Years
Discussion Span
Last Post by Ramesh S
1

Try this code.

using System;

public class Calculator
{
public static void Main()
{
int num1;
int num2;
string operand;
float answer;


Console.Write("Please enter the first integer: ");
num1 = Convert.ToInt32(Console.ReadLine());


Console.Write("Please enter an operand (+, -, /, *): ");
operand = Console.ReadLine();


Console.Write("Please enter the second integer: ");
num2 = Convert.ToInt32(Console.ReadLine());

switch (operand)
{
case "-":
answer = num1 - num2;
break;
case "+":
answer = num1 + num2;
break;
case "/":
answer = num1 / num2;
break;
case "*":
answer = num1 * num2;
break;
default:
answer = 0;
break;
}

Console.WriteLine(num1.ToString() + " " + operand + " " + num2.ToString() + " = " + answer.ToString());

Console.ReadLine();

}
}

Reference: http://www.devpapers.com/article/288

Also refer this link: Console calculator Part 1

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.