Advertisement
ra1n

Console Calculator

Dec 9th, 2013
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.37 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 ConsoleApp
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             /* Project by Ra1n */
  15.  
  16.             string Name;
  17.  
  18.             // Name input and output.
  19.             Console.WriteLine();
  20.             Console.ForegroundColor = ConsoleColor.Cyan;
  21.             Console.Write("  Enter your name: ");
  22.             Name = Convert.ToString(Console.ReadLine());
  23.             Console.Clear();
  24.             Console.WriteLine();
  25.             Console.WriteLine("  Hello, " + Name);
  26.             Console.WriteLine();
  27.            
  28.             // First input value.
  29.             Console.ForegroundColor = ConsoleColor.Red;
  30.             Console.Write("  Enter a number: ");
  31.             int x = Convert.ToInt32(Console.ReadLine());
  32.             Console.WriteLine();
  33.  
  34.             // Second input value.
  35.             Console.Write("  Enter another number: ");
  36.             int y = Convert.ToInt32(Console.ReadLine());
  37.             Console.WriteLine();
  38.  
  39.             // Sum options.
  40.             Console.ForegroundColor = ConsoleColor.Yellow;
  41.             Console.WriteLine("  Enter 1 for addition");
  42.             Console.WriteLine("  Enter 2 for subtraction");
  43.             Console.WriteLine("  Enter 3 for multiplication");
  44.             Console.WriteLine("  Enter 4 for division");
  45.             Console.WriteLine();
  46.  
  47.             // Select option.
  48.             Console.ForegroundColor = ConsoleColor.Yellow;
  49.             Console.Write("  Option: ");
  50.             int z = Convert.ToInt32(Console.ReadLine());
  51.             Console.WriteLine();
  52.  
  53.             Console.Clear();
  54.  
  55.             // Sum Answer
  56.             Console.WriteLine();
  57.             Console.ForegroundColor = ConsoleColor.Green;
  58.             Console.Write("  The answer is: ");
  59.             switch (z)
  60.             {
  61.                 case 1:
  62.                     Console.WriteLine(x + y);
  63.                     break;
  64.                 case 2:
  65.                     Console.WriteLine(x - y);
  66.                     break;
  67.                 case 3:
  68.                     Console.WriteLine(x * y);
  69.                     break;
  70.                 case 4:
  71.                     Console.WriteLine(x - y);
  72.                     break;
  73.             }
  74.  
  75.             Console.ReadKey();
  76.  
  77.         }
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement