Advertisement
callumbinner22

Stack Task 1

Dec 9th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.74 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace ConsoleApplication50
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             int x = 0;
  15.             Stack employee = new Stack();
  16.             employee.Push("Callum");
  17.             employee.Push("Matt");
  18.             employee.Push("Harry");
  19.             employee.Push("Jacob");
  20.  
  21.             while (x < 1)
  22.             {
  23.             int input;
  24.  
  25.          
  26.  
  27.             Console.WriteLine(" 1) Enter new employee name");
  28.             Console.WriteLine(" 2) Check who is at top of redundancy list. ");
  29.             Console.WriteLine(" 3) Remove employee who has been made redundant. ");
  30.             input = Convert.ToInt32(Console.ReadLine());
  31.            
  32.             if (input == 1)
  33.             {
  34.                 Console.WriteLine("Enter New Employee's name ");
  35.                 string newemployee = Console.ReadLine();
  36.                 employee.Push(newemployee);
  37.             }
  38.  
  39.             if (input == 2)
  40.             {
  41.                 Console.WriteLine(employee.Peek());
  42.             }
  43.             else if (input ==3)
  44.             {
  45.                 Console.WriteLine("Erasing " + employee.Peek());
  46.                 employee.Pop();
  47.                 Console.WriteLine("It is done!");
  48.             }
  49.             Console.WriteLine("Would you like to continue?");
  50.             string decision = Console.ReadLine();
  51.                 if ( decision == "yes")
  52.                 {
  53.                     x = 0;
  54.                 }
  55.                 else if (decision == "no")
  56.                 {
  57.                     x=1;
  58.                 }
  59.  
  60.             }
  61.  
  62.  
  63.         }
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement