Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Switch_case
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- int input;
- do
- {
- Console.Clear();
- Console.WriteLine("Vending Machine:");
- Console.WriteLine("1: Coffee");
- Console.WriteLine("2: Tea");
- Console.WriteLine("3: Water");
- Console.WriteLine("4: Juice");
- Console.WriteLine("5: Exit");
- Console.Write("Choose a drink (1-5): ");
- input = int.Parse(Console.ReadLine());
- switch (input)
- {
- case 1:
- Console.WriteLine("Here's your coffee!");
- break;
- case 2:
- Console.WriteLine("Here's your tea!");
- break;
- case 3:
- Console.WriteLine("Here's your water!");
- break;
- case 4:
- Console.WriteLine("Here's your juice!");
- break;
- case 5:
- Console.WriteLine("Thank you! Bye bye!");
- break;
- default:
- Console.WriteLine("Wrong choice! Try again!");
- break;
- }
- /*
- if (input == 1)
- Console.WriteLine("Here's your coffee!");
- if (input == 2)
- Console.WriteLine("Here's your tea!");
- if (input == 3)
- Console.WriteLine("Here's your water!");
- if (input == 4)
- Console.WriteLine("Here's your juice!");
- if (input == 5)
- Console.WriteLine("Thank you! Bye bye!");
- if (input != 1 && input != 2 && input != 3 && input != 4 && input != 5)
- Console.WriteLine("Wrong choice! Try again!");
- */
- Console.ReadKey();
- } while (input != 5);
- }
- }
- }
- /*
- Objective:
- Create a program that acts as a simple calculator.
- The program should allow the user to choose a mathematical
- operation from a menu, input two numbers, and then display the result.
- The selection of operations should be handled using a switch-case statement.
- Requirements:
- Menu of Operations:
- 1: Addition (+)
- 2: Subtraction (-)
- 3: Multiplication (*)
- 4: Division (/)
- 5: Exit
- Input:
- The user selects an operation from the menu by entering a number (1-5).
- The program then prompts the user to input two numbers for the calculation.
- Calculation:
- Perform the chosen operation on the two numbers.
- For division, ensure that the second number is not zero. If zero is entered,
- display an error message.
- Exit:
- The program should loop until the user selects "5: Exit".
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement