Frank

Frank

  • NA
  • 16
  • 22.7k

Need help on a calculator I'm making.

Jan 30 2011 1:22 AM
I'm making a calculator that lets you choose what you want to do. 
Add, Subtract, Divide, or Multiply. and I'm running into a problem, I'm trying to make it so if the user presses the + button it will automatically clear the screen(Which I haven't added to the code) and ask for the numbers. 
The problem is it does not advance once the user chooses this.

Oh and also I'm a kind of new to C#. I'm not sure if the Convert.ToInt32's are necessary.

         static void Main(string[] args)
        
{
            
int Var1 = 0, Var2 = 0;
            
int userinput = 0;
            
Console.WriteLine("Addition (+), Subtraction (-), Division (/), or Multiplicaton (*)");
            
Console.ReadLine();
            
if (userinput == '+')
            
{
                
Console.WriteLine("Enter The First Number You Would Like To Add: ");
                
Var1 = Convert.ToInt32(Console.ReadLine());
                
Console.WriteLine("Enter The Second Number You Would Like To Add: ");
                
Var2 = Convert.ToInt32(Console.ReadLine());
                
Console.WriteLine("The Answer Is: ");
                
Console.WriteLine(Var1 + Var2);
            
}
        
}


Answers (9)