Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.97 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleCalculator
  8. {
  9.     public class Calculator
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int firstNumber;
  14.             int secondNumber;
  15.  
  16.             Console.WriteLine("Hi, write a first number and press Enter");
  17.             firstNumber = int.Parse(Console.ReadLine());
  18.  
  19.             Console.WriteLine("ok, write a second number and press Enter");
  20.             secondNumber = int.Parse(Console.ReadLine());
  21.  
  22.             Console.WriteLine("What do you want to do with these numbers?");
  23.             Console.WriteLine("write + to add");
  24.             Console.WriteLine("write - to substract ");
  25.             Console.WriteLine("write * multiply");
  26.             Console.WriteLine("write / divide");
  27.  
  28.             switch (Console.ReadLine())
  29.             {
  30.                 case "+":
  31.                     Add(firstNumber, secondNumber);
  32.                     break;
  33.                 case "-":
  34.                     Substract(firstNumber, secondNumber);
  35.                     break;
  36.                 case "*":
  37.                     Multiply(firstNumber, secondNumber);
  38.                     break;
  39.                 case "/:
  40.                    Dvide(firstNumber, secondNumber);
  41.                    break;
  42.            }
  43.        }
  44.  
  45.        public int Add(int a, int b)
  46.        {
  47.            int score = 0;
  48.            score = a + b;
  49.            return Console.WriteLine(score);
  50.        }
  51.  
  52.        public int Substract(int a, int b)
  53.        {
  54.            int score = 0;
  55.            score = a - b;
  56.            return score;
  57.        }
  58.  
  59.        public int Multiply(int a, int b)
  60.        {
  61.            int score = 0;
  62.            score = a * b;
  63.            return score;
  64.        }
  65.  
  66.        public double Divide(int a, int b)
  67.        {
  68.            int score = 0;
  69.            score = a / b;
  70.            return score;
  71.        }
  72.    }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement