|
-
September 16th, 2015, 11:36 AM
#1
Newb trying to learn C# / stuck
Hello there,
I've just started getting into C# and of course, the first thing I wanted to make was a calculator.. aaaaand I'm stuck..
This is what I have:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Calculator
{
class Program
{
static void Main(string[] args)
{
Start:
string nr1;
float nr2;
float nr3;
Console.Write("Enter a calculation operation symbol which you'd like to use: ");
nr1 = Console.ReadLine();
Console.Write("Enter the first number: ");
nr2 = Console.ReadLine();
Console.Write("Enter the second number: ");
nr3 = Console.ReadLine();
if (nr1 == "+")
{
goto Addition;
}
else if (nr1 == "-")
{
goto Subtraction;
}
else if (nr1 == "/")
{
goto Dividing;
}
else if (nr1 == "*")
{
goto Multiplying;
}
else Console.Write("Incorrect Entry, try again!");
goto Start;
Addition:
Console.Clear();
Console.WriteLine("The result is: " + (nr2 + nr3));
Console.ReadKey();
Console.Clear();
goto Start;
Subtraction:
Console.Clear();
Console.WriteLine("The result is: " + (nr2 - nr3));
Console.ReadKey();
Console.Clear();
goto Start;
Dividing:
Console.Clear();
Console.WriteLine("The result is: " + (nr2 * nr3));
Console.ReadKey();
Console.Clear();
goto Start;
Multiplying:
Console.Clear();
Console.WriteLine("The result is: " + (nr2 / nr3));
Console.ReadKey();
Console.Clear();
goto Start;
}
}
}
Addition and Subtraction seem to work, but multiplaying and dividing don't.
Your help would be appreciated!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|