@CycleWeeb/

calculator

C#

No description

fork
loading
Files
  • main.cs
  • main.exe
main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;

class MainClass {
  public static void Main (string[] args) {
    double num1 = 0;
		double num2 = 0;
    char operat = 'a';
    while(true){
      num1 = Convert.ToDouble(Console.ReadLine());
      operat = Convert.ToChar(Console.ReadLine());
      num2 = Convert.ToDouble(Console.ReadLine());
      switch (operat){
        case '+':
        Console.WriteLine(num1 + num2);
        break;

        case '-':
        Console.WriteLine(num1 - num2);
        break;

        case '*':
        Console.WriteLine(num1 * num2);
        break;

        case '/':
        Console.WriteLine(num1 / num2);
        break;

        case '%':
        Console.WriteLine(num1 % num2);
        break;

        case '^':
        Console.WriteLine((Math.Pow(num1,num2)));
        break;

        case '@':
        Console.WriteLine((Math.Sqrt(num1)));
        break;

				default:
				Console.WriteLine("Please select a valid operator: + for plus, - for minus, * for times, / for divide, % for modulus, ^ for power, and @ for square root (second number does not matter)");
				break;
      }
    }
  }
}