2 Replies - 2720 Views - Last Post: 12 May 2010 - 09:13 PM Rate Topic: -----

#1 bentodd  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 13
  • Joined: 12-May 10

problems with calculator in Visual Studio

Posted 12 May 2010 - 08:08 PM

I am writing a simple calculator in Visual Studio for my class. I am having problems with my array for the equations and my Command prompt won't stay running so I can test my code. I have only rewritten it through the addition part of my case structure and I am not getting any errors. Any help would be much appreciated.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Project_2_2
{
    class Program
    {
        static void Main()
        {
            double num1;
            double num2;
            double total;
            string [] equation = { num1 + num2, num1 - num2, num1 * num2,num1 / num2};
            string inputString = Console.ReadLine;
            string input = inputString.Split(',');
            
            const string QUIT = "quit";
            Console.ReadLine();

            Console.WriteLine("Enter equation");
            equation[4] = Convert.ToDouble(Console.ReadLine());
            

            while (equation.Length != 0)
           
            {
                if (equation[4] = QUIT)
                    Console.WriteLine("GoodBye");
                     
 
                while (oper != QUIT)
                    
                {
                        

                        switch (equation)
                        {
                            case equation[0]:
                                total = num1 + num2;
                                Console.WriteLine("{0} {1} {2} = {3}", equation[0], total);
                                num1 = total;
                                break;
                            case "-":
                                Console.WriteLine("Enter number");
                                num2 = Convert.ToDouble(Console.ReadLine());
                                total = num1 - num2;
                                Console.WriteLine("{0} {1} {2} = {3}", num1, oper, num2, total);
                                num1 = total;
                                break;
                            case "*":
                                Console.WriteLine("Enter number");
                                num2 = Convert.ToDouble(Console.ReadLine());
                                total = num1 * num2;
                                Console.WriteLine("{0} {1} {2} = {3}", num1, oper, num2, total);
                                num1 = total;
                                break;
                            case "/":
                                Console.WriteLine("Enter number");
                                num2 = Convert.ToDouble(Console.ReadLine());
                                total = num1 / num2;
                                Console.WriteLine("{0} {1} {2} = {3}", num1, oper, num2, total);
                                num1 = total;
                                break;
                            case "=":
                                
                                Console.WriteLine("Enter number");
                                num1 = Convert.ToDouble(Console.ReadLine());
                                
                          
                                break;
                            case "QUIT":
                                Console.WriteLine("Thank You for using my calculator!");
                                Console.ReadLine();
                                return;
                               
                            default:
                                Console.WriteLine("Re-enter operation");
                                oper = Convert.ToString(Console.ReadLine());                                                           
                                break;









                        } Console.ReadLine();


                } 
            } 
            
                }
           

              
        }
    }





Is This A Good Question/Topic? 0
  • +

Replies To: problems with calculator in Visual Studio

#2 Momerath  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1020
  • View blog
  • Posts: 2,463
  • Joined: 04-October 09

Re: problems with calculator in Visual Studio

Posted 12 May 2010 - 08:43 PM

There are so many errors in that code, errors that make it so it won't compile, so I have no idea what you mean when you say "I am not getting any errors".
Was This Post Helpful? 1
  • +
  • -

#3 bentodd  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 13
  • Joined: 12-May 10

Re: problems with calculator in Visual Studio

Posted 12 May 2010 - 09:13 PM

Yeah I realize that now. I copied and pasted into a new project and found out that I am truly lost in this. Any help would be appreciated, atleast to get me on the right track. Thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1