# Ideas for c# calculator

Hey, I’m making a calculator in C# using dotnetfiddle terminals, and I was wondering about any additions that you guys would make to it.

It is capable of addition, subtraction, multiplication, division, exponents, logarithms, and whole random number generation (set by user limits).

Here’s the code. If you can find of a way to streamline it, it would also be appreciated.

``````using System;
public class Program{
public static void Main(){
Console.WriteLine("Welcome to the basic calculator\n-------------------------------\n");
while (true){
Console.WriteLine("Here are the available functions: \n\n1. Addition\n2. Subtraction\n3. Multiplication\n4. Division\n5. Exponent\n6. Logarithm\n7. Random number generator\n\nSelect a function by its number: ");
if (pemdas == "1"){
Console.WriteLine("insert first number: ");
Console.WriteLine("insert second number: ");
Console.WriteLine("\nYour result is: " + (firstNum + secondNum) + "\n\n\n");
}else if (pemdas == "2"){
Console.WriteLine("insert starting value: ");
Console.WriteLine("insert value removed: ");
Console.WriteLine("\n your resulting value is: " + (firstNum - secondNum) + "\n\n\n");
}else if (pemdas == "3"){
Console.WriteLine("How much are you multiplying this number by: ");
Console.WriteLine("\nYour result is: " + (firstNum * secondNum) + "\n\n\n");
}else if (pemdas == "4"){
Console.WriteLine("How much are you dividing this number by? ");
Console.WriteLine("\nYour resulting value is: " + (firstNum / secondNum) + "\n\n\n");
}else if (pemdas == "5"){
double baseNum = 2.71828;
Console.WriteLine("Enter the power: ");
Console.WriteLine("\nYour result is: " + Math.Pow(baseNum, exponent) + "\n\n\n");
}else{
Console.WriteLine("Enter the power: ");
Console.WriteLine("\nYour result is: " + Math.Pow(baseNum, exponent) + "\n\n\n");
}
}else if (pemdas == "6"){
double logBase = 2.71828;
Console.WriteLine("What is the other thing: ");
Console.WriteLine("The result is: " + Math.Log(thingValue, logBase));
}else{
Console.WriteLine("What is the other thing: ");
Console.WriteLine("The result is: " + Math.Log(thingValue, logBase));
}
}else if(pemdas=="7"){
Random rnd = new Random();
Console.WriteLine("WHOLE NUMBERS ONLY");
Console.WriteLine("Lower bound: ");
Console.WriteLine("Upper bound: ");
int compChoice = rnd.Next(lowerB, upperB);
}
}
}
}
``````
1 Like

Kewl

Because

1 Like

Yeesh, that is going to be something difficult to do, as I’d have to do an open form calculator which are much harder to make.

2 Likes

I’m trying to make one in Scratch :]

Thats why I suggested it \

You forgot base converting, such as decimal to binary :] you could look at my TypeScript code on Github for ideas of how to do it

Is your base converter fast? I didn’t read all the code (yet).

It’s pretty much instant

Since computers are really fast lol

1 Like

I also tried to make a calculator on C++ but not in C# using dotnetfiddle terminals.

I tried your code but every time the result of a function comes out it always appears above and not below in the foreground. When the result of a function comes out you could make it more visible.

Maybe when the result of a function comes out for example addition etc., you could put like “Press a key on the keyboard to go back”, and when you press it it brings you back to the available functions “here are the available functions”.

Here is:

Thank you, I will put this into consideration

1 Like