Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleCalculator
- {
- public class Calculator
- {
- static void Main(string[] args)
- {
- int firstNumber;
- int secondNumber;
- Console.WriteLine("Hi, write a first number and press Enter");
- firstNumber = int.Parse(Console.ReadLine());
- Console.WriteLine("ok, write a second number and press Enter");
- secondNumber = int.Parse(Console.ReadLine());
- Console.WriteLine("What do you want to do with these numbers?");
- Console.WriteLine("write + to add");
- Console.WriteLine("write - to substract ");
- Console.WriteLine("write * multiply");
- Console.WriteLine("write / divide");
- switch (Console.ReadLine())
- {
- case "+":
- Add(firstNumber, secondNumber);
- break;
- case "-":
- Substract(firstNumber, secondNumber);
- break;
- case "*":
- Multiply(firstNumber, secondNumber);
- break;
- case "/:
- Dvide(firstNumber, secondNumber);
- break;
- }
- }
- public int Add(int a, int b)
- {
- int score = 0;
- score = a + b;
- return Console.WriteLine(score);
- }
- public int Substract(int a, int b)
- {
- int score = 0;
- score = a - b;
- return score;
- }
- public int Multiply(int a, int b)
- {
- int score = 0;
- score = a * b;
- return score;
- }
- public double Divide(int a, int b)
- {
- int score = 0;
- score = a / b;
- return score;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement