Advertisement
_CodeBehind

GoToExample

Aug 7th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.65 KB | None | 0 0
  1.  Console.WriteLine("Coffee sizes: 1=Small 2=Medium 3=Large");
  2.             Console.Write("Please enter your selection: ");
  3.             string s = Console.ReadLine();
  4.             int n = int.Parse(s);
  5.             int cost = 0;
  6.             switch (n)
  7.             {
  8.                 case 1:
  9.                     cost += 25;
  10.                     break;
  11.                 case 2:
  12.                     cost += 25;
  13.                     goto case 1;
  14.                 case 3:
  15.                     cost += 50;
  16.                     goto case 1;
  17.                 default:
  18.                     Console.WriteLine("Invalid selection.");
  19.                     break;
  20.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement