Click here to Skip to main content
15,887,477 members
Home / Discussions / C#
   

C#

 
AnswerRe: designing around the need for an abstract static method Pin
Gerry Schmitz2-Apr-18 6:44
mveGerry Schmitz2-Apr-18 6:44 
AnswerRe: designing around the need for an abstract static method Pin
BillWoodruff2-Apr-18 21:43
professionalBillWoodruff2-Apr-18 21:43 
GeneralRe: designing around the need for an abstract static method Pin
Alexander Kindel7-Apr-18 16:06
Alexander Kindel7-Apr-18 16:06 
GeneralRe: designing around the need for an abstract static method Pin
Alexander Kindel8-Apr-18 0:57
Alexander Kindel8-Apr-18 0:57 
AnswerC# Pin
Member 137573041-Apr-18 8:59
Member 137573041-Apr-18 8:59 
GeneralRe: C# Pin
OriginalGriff1-Apr-18 8:31
mveOriginalGriff1-Apr-18 8:31 
GeneralRe: C# Pin
PIEBALDconsult1-Apr-18 9:01
mvePIEBALDconsult1-Apr-18 9:01 
QuestionPlease help me with my basic c# calculator loop function Pin
Florence Gray31-Mar-18 15:46
Florence Gray31-Mar-18 15:46 
Hiya,
I am a complete beginner and need help with the loop function,
I have written my code but it doesnt run exactly as I need it to. Please help me!!
Florence needs help with C Sharp Programming as soon as possible. Florence wrote:
I am stuck on a basic c# calculator using the loop function, my loop function wont correctly loop.. please help!!

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

namespace Calculatorattemptone
    {
    class Program
        {
        static void Main(string[] args)
            {

            Console.WriteLine("Calculator");
            Console.WriteLine("***********************************************************");
            Console.WriteLine("1 - Claculation");
            Console.WriteLine("2 - Exit");
            Console.Write("Please enter your option here: ");
            bool incorrect = true;
            while (incorrect)
                {
                string option = Console.ReadLine();
                if (option != "1" || option != "2")
                    {
                    incorrect = true;

                        {
                        Console.WriteLine("Invalid option");
                        Console.WriteLine("1 - Claculation");
                        Console.WriteLine("2 - Exit");
                        Console.Write("Please enter your option here: ");

                        }
                    }

                if (option == "2")
                    {
                    incorrect = false;
                        {
                        System.Environment.Exit(0);
                        }
                    }

                if (option == "1")
                    {
                    incorrect = false;

                        {
                        Console.WriteLine("A - Addition");
                        Console.WriteLine("S - Subtraction");
                        Console.WriteLine("D - Division");
                        string equation = Console.ReadLine();

                        if (equation == "A")
                            {
                            equation = "1";
                            }
                        else if (equation == "S")
                            {
                            equation = "2";
                            }
                        else if (equation == "D")
                            {
                            equation = "3";
                            }
                        else
                            {
                            Console.WriteLine("ERROR: Unsupported Calculation");
                            }

                        Console.WriteLine("Enter your first number:");
                        int firstNumber = Int32.Parse(Console.ReadLine());
                        Console.WriteLine("Enter your second number:");
                        int ScndNumber = Int32.Parse(Console.ReadLine());
                        int result;
                        switch (equation)
                            {
                            case "1":

                                result = (firstNumber + ScndNumber);
                                Console.WriteLine("RESULT: " + result);
                                break;

                            case "2":

                                result = (firstNumber - ScndNumber);
                                Console.WriteLine("RESULT: " + result);
                                break;

                            case "3":

                                result = (firstNumber / ScndNumber);
                                Console.WriteLine("RESULT: " + result);
                                break;

                            default:

                                Console.WriteLine("Error Unsuported Calculation");
                                break;

                            }

                        Console.WriteLine("Press any key to continue....");
                        Console.ReadKey();
                        }
                    }
                }
            }
        }
    }


[edit]Code block added - OriginalGriff[/edit]

modified 1-Apr-18 1:56am.

AnswerRe: Please help me with my basic c# calculator loop function Pin
OriginalGriff31-Mar-18 20:00
mveOriginalGriff31-Mar-18 20:00 
AnswerRe: Please help me with my basic c# calculator loop function Pin
Richard MacCutchan31-Mar-18 20:58
mveRichard MacCutchan31-Mar-18 20:58 
RantCoding error missing reference Pin
uighgg ojgeojge31-Mar-18 1:36
uighgg ojgeojge31-Mar-18 1:36 
AnswerRe: Coding error missing reference Pin
OriginalGriff31-Mar-18 1:47
mveOriginalGriff31-Mar-18 1:47 
QuestionRe: Coding error missing reference Pin
uighgg ojgeojge31-Mar-18 1:58
uighgg ojgeojge31-Mar-18 1:58 
GeneralRe: Coding error missing reference Pin
OriginalGriff31-Mar-18 2:28
mveOriginalGriff31-Mar-18 2:28 
GeneralRe: Coding error missing reference Pin
uighgg ojgeojge31-Mar-18 2:34
uighgg ojgeojge31-Mar-18 2:34 
GeneralRe: Coding error missing reference Pin
Dave Kreskowiak31-Mar-18 8:36
mveDave Kreskowiak31-Mar-18 8:36 
GeneralRe: Coding error missing reference Pin
Pete O'Hanlon31-Mar-18 10:12
mvePete O'Hanlon31-Mar-18 10:12 
QuestionProblem with Rotating Platforms in Unity 3D Pin
O.G.I.30-Mar-18 8:06
O.G.I.30-Mar-18 8:06 
AnswerRe: Problem with Rotating Platforms in Unity 3D Pin
Eddy Vluggen30-Mar-18 22:48
professionalEddy Vluggen30-Mar-18 22:48 
GeneralRe: Problem with Rotating Platforms in Unity 3D Pin
O.G.I.30-Mar-18 23:51
O.G.I.30-Mar-18 23:51 
GeneralRe: Problem with Rotating Platforms in Unity 3D Pin
Eddy Vluggen31-Mar-18 3:10
professionalEddy Vluggen31-Mar-18 3:10 
QuestionIPv6 based UDP client which can communicate with 3rd Part IPv6 based UDP Server Pin
SKant0330-Mar-18 0:15
SKant0330-Mar-18 0:15 
AnswerRe: IPv6 based UDP client which can communicate with 3rd Part IPv6 based UDP Server Pin
Gerry Schmitz31-Mar-18 6:50
mveGerry Schmitz31-Mar-18 6:50 
QuestionHow to fix this? Please see my code if what is the solution for 'AssetService.InsertPulloutReturnItems(string, string, string, string)': not all code paths return value.. Thanks Pin
arthur tarrayo29-Mar-18 21:05
arthur tarrayo29-Mar-18 21:05 
AnswerRe: How to fix this? Please see my code if what is the solution for 'AssetService.InsertPulloutReturnItems(string, string, string, string)': not all code paths return value.. Thanks Pin
OriginalGriff29-Mar-18 21:23
mveOriginalGriff29-Mar-18 21:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.