Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner; //importing scanner
- public class individual_activity { //program begins
- public static void main(String[] args) {
- //Done by: me
- Scanner input = new Scanner (System.in);
- //declaring variable
- int menu;
- //letting users input the variable
- System.out.println("Enter options 1 to 5 or 0 to exit: ");
- menu = input.nextInt();
- while(menu != 0) { //while loop is used as a continuous loop, and it can be exited with 0 is entered.
- switch(menu) { //switch statement is used to display the option chosen.
- case 1: System.out.println("You chose option 1.");
- break;
- case 2: System.out.println("You chose option 2.");
- break;
- case 3: System.out.println("You chose option 3.");
- break;
- case 4: System.out.println("You chose option 4.");
- break;
- case 5: System.out.println("You chose option 5.");
- break;
- default: System.out.println("Invalid Code.");
- } //switch statement ends
- System.out.println("Enter options 1 to 5 or 0 to exit: ");
- menu = input.nextInt();
- } //while loop ends
- System.out.println("Thank you for using this menu."); //displays when user enters 0
- }
- } //program ends
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement