Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Net;
- using System.Threading;
- namespace Calculator
- {
- class Calculator
- {
- static void Main(string[] args)
- {
- // Character Variables
- char plus = '+';
- char minus = '-';
- char division = '/';
- char multiply = '*';
- // Intro
- Console.WriteLine("Welcome to Calculator!");
- Console.WriteLine("");
- Console.WriteLine("Made by Aleksandar!");
- Console.WriteLine("");
- // Number 1
- Console.Write("Choose your first number : ");
- string number1 = Console.ReadLine();
- int num1 = Convert.ToInt32(number1);
- Console.WriteLine("");
- // Number 2
- Console.Write("Choose your second number : ");
- string number2 = Console.ReadLine();
- int num2 = Convert.ToInt32(number2);
- Console.WriteLine("");
- // Operation
- Console.Write("Choose your operation (+, -, *, /) : ");
- string operation = Console.ReadLine();
- Console.WriteLine("");
- // Answer
- if (operation == Convert.ToString(plus))
- {
- Console.WriteLine("The answer is : ");
- Console.WriteLine("");
- Console.Write(number1 + " + " + number2 + " = ");
- Console.Write(num1 + num2);
- Console.WriteLine("");
- }
- else if (operation == Convert.ToString(minus))
- {
- Console.WriteLine("The answer is : ");
- Console.WriteLine("");
- Console.Write(number1 + " + " + number2 + " = ");
- Console.Write(num1 - num2);
- Console.WriteLine("");
- }
- else if (operation == Convert.ToString(division))
- {
- Console.WriteLine("The answer is : ");
- Console.WriteLine("");
- Console.Write(number1 + " + " + number2 + " = ");
- Console.Write(num1 / num2);
- Console.WriteLine("");
- }
- else if (operation == Convert.ToString(multiply))
- {
- Console.WriteLine("The answer is : ");
- Console.WriteLine("");
- Console.Write(number1 + " + " + number2 + " = ");
- Console.Write(num1 * num2);
- Console.WriteLine("");
- }
- // Outro
- Console.WriteLine("");
- Console.WriteLine("Thank you for using calculator!");
- Console.WriteLine("");
- // Program keeps running
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement