[nfbcs] Help with calculater program for windows

Taylor Arndt taylorarndt99 at gmail.com
Fri Mar 10 23:58:49 UTC 2017


Hi,
So i have been working on this little program for some time, and i
have done well with it but running into issues because it won't accept
decimal numbers, and also  i would love to have it so when you press
escape it exits the program Here is my code


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Accessible_Calculater
{
    class Program
    {
        private static object e;
        private static int num1;

        public static string Keypressed { get; private set; }
        public static object Keys { get; private set; }
        public static object Answer { get; private set; }

        static void Main(string[] args)
        {
            while (true)
            {

                 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();
            }
        }
    }
}
Thanks and i really apreciate the help i can get with this manner
Thanks
Taylor

-- 
Taylor




More information about the NFBCS mailing list