Advertisement
Guest User

Untitled

a guest
Jul 7th, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.51 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 CalculatorOne
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             double num01;
  14.             double num02;
  15.             int userChoice = 1;
  16.  
  17.             Console.Write ("First Number: ");
  18.             num01 = double.Parse (Console.ReadLine());
  19.  
  20.             Console.WriteLine ("\nPlease select from one of the following options (1-4)");
  21.             Console.WriteLine ("1 - Addition");
  22.             Console.WriteLine ("2 - Subtraction");
  23.             Console.WriteLine ("3 - Division");
  24.             Console.WriteLine ("4 - Multiplication");
  25.  
  26.             start:
  27.  
  28.             userChoice = Int32.Parse (Console.ReadLine());
  29.  
  30.             switch (userChoice) //Used a bit like an if statement, but tidier and more efficient in this project
  31.             {
  32.                 case 1:
  33.                     Console.WriteLine("\nAddition Selected: ");
  34.                     Console.Write("\nSecond Number: ");
  35.                     num02 = double.Parse(Console.ReadLine());
  36.                     Console.WriteLine ("\nTotal: " + num01 + " + " + num02 + " = " + (num01 + num02));
  37.                     break;
  38.  
  39.                 case 2:
  40.                     Console.WriteLine("\nSubtraction Selected: ");
  41.                     Console.Write("\nSecond Number: ");
  42.                     num02 = double.Parse(Console.ReadLine());
  43.                     Console.WriteLine("\nTotal: " + num01 + " - " + num02 + " = " + (num01 - num02));
  44.                     break;
  45.  
  46.                 case 3:
  47.                     Console.WriteLine("\nDivision Selected: ");
  48.                     Console.Write("\nSecond Number: ");
  49.                     num02 = double.Parse(Console.ReadLine());
  50.                     Console.WriteLine("\nTotal: " + num01 + " / " + num02 + " = " + (num01 / num02));
  51.                     break;
  52.  
  53.                 case 4:
  54.                     Console.WriteLine("\nMultiplication Selected: ");
  55.                     Console.Write("\nSecond Number: ");
  56.                     num02 = double.Parse(Console.ReadLine());
  57.                     Console.WriteLine("\nTotal: " + num01 + " x " + num02 + " = " + (num01 * num02));
  58.                     break;
  59.  
  60.                 default:
  61.                     Console.WriteLine("Sorry incorrect input, please select one of the four options listed above.");
  62.                     break;
  63.  
  64.                }
  65.  
  66.             Console.ReadLine();
  67.  
  68.         }
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement