Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. using System;
  2.  
  3. namespace prac6_Q2
  4.  
  5. {
  6.  
  7. class menu
  8.  
  9. {
  10.  
  11. static void Main(string[] args)
  12.  
  13. {
  14.  
  15. int response = 0;
  16.  
  17. string tempVal = "";
  18.  
  19. bool parseAttempt = false;
  20.  
  21.  
  22.  
  23. while (response != 4)
  24.  
  25. {
  26.  
  27. // Display the menu
  28. Console.WriteLine("1. Make a phone call");
  29.  
  30. Console.WriteLine("2. Send an SMS");
  31.  
  32. Console.WriteLine("3. Find a contact");
  33.  
  34. Console.WriteLine("4. Quit");
  35.  
  36. Console.Write("Enter your selection > ");
  37.  
  38.  
  39. // Get the users response
  40. tempVal = Console.ReadLine();
  41.  
  42. parseAttempt = Int32.TryParse(tempVal, out response);
  43.  
  44. if (parseAttempt == false)
  45.  
  46. {
  47.  
  48. response = 0;
  49.  
  50. }
  51.  
  52. // Process the response
  53.  
  54. switch (response)
  55.  
  56. {
  57.  
  58. case 1:
  59.  
  60. Console.WriteLine("User selected to make a phone call, option " + response);
  61.  
  62. break;
  63.  
  64. case 2:
  65.  
  66. Console.WriteLine("User selected to send an SMS, option " + response);
  67.  
  68. break;
  69.  
  70. case 3:
  71.  
  72. Console.WriteLine("User selected to find a contact, option " + response);
  73.  
  74. break;
  75.  
  76. case 4:
  77.  
  78. Console.WriteLine("User selected to Quit, option " + response);
  79.  
  80. break;
  81.  
  82. default:
  83.  
  84. Console.WriteLine("Unknown selection, option " + response);
  85.  
  86. break;
  87.  
  88. }
  89.  
  90. }
  91.  
  92. Console.ReadLine();
  93.  
  94. }
  95.  
  96. }
  97.  
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement