Take a look into the code I did only for you. Its a code, which allows the user to insert as many numbers and operands as he wants to create a formula.
On the end, when he wants to create an out put, he only inserts the enter after number:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Jan22Calculator
{
class Program
{
static void Main(string[] args)
{
bool bEnd = false;
decimal total = 0M;
decimal number = 0M;
string strOperand = null;
string strFormula = null;
int counter = 1;
Console.WriteLine("Calculator: Please enter number by number, seperated by operands.");
Console.WriteLine("To get the result, simply write the equals sing just after number (X=)");
do
{
string word = GetCounter(counter);
Console.WriteLine("Please enter the " + word + " number:");
string strNumber = Console.ReadLine();
if (strNumber.Contains("="))
{
strNumber = strNumber.Remove(strNumber.Length - 1, 1);
bEnd = true;
}
bool bChecking = CheckingNumber(strNumber);
if (bChecking)
{
strFormula += strNumber;
counter++;
number = Convert.ToDecimal(strNumber);
total = GetTotal(number, total, strOperand);
bChecking = false;
while (!bChecking && !bEnd)
{
Console.WriteLine("Please enter the operand (+, -, /, *):");
strOperand = Console.ReadLine();
bChecking = CheckingOperand(strOperand);
if (bChecking)
strFormula += strOperand;
else
Console.WriteLine("Wrong operand.");
}
}
else
Console.WriteLine("This is not the number.");
}
while (!bEnd);
//on the end it shows the final result:
strFormula = strFormula + "=";
Console.WriteLine("{0}{1}", strFormula, total.ToString());
Console.ReadLine();
}
public static string GetCounter(int counter)
{
string word = null;
string[] words = { "1st", "2nd", "3rd" };
if (counter < 3)
word …