Advertisement
Felanpro

simple calculator

Aug 9th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.15 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 csharp_youtube_tutorial
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             //Addition and subtraction calculator. (Simple)
  14.             //This calculator is only limited to addition and subtraction operating<--!-->
  15.             double num1; //We could just do float to save memory but fuck it.
  16.             double num2;
  17.  
  18.             Console.Write("First number: ");
  19.             num1 = Convert.ToDouble(Console.ReadLine()); /*The method ReadLine() takes the input as a string, so you have to convert it
  20.             into a double.*/
  21.             Console.Write("Second number: ");
  22.             num2 = Convert.ToDouble(Console.ReadLine());
  23.  
  24.             double addition_sum = num1 + num2;
  25.             double subtraction_sum = num1 - num2;
  26.  
  27.             Console.WriteLine("Addition: " + addition_sum);
  28.             Console.WriteLine("Subtraction: " + subtraction_sum);
  29.  
  30.             Console.ReadKey(); //Press a key application ends. //Console[Class] ReadKey()[Function/Method]  
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement