Respuesta :
Answer:
Explanation:
import java.util.Scanner;
public class Menu {
 public static void main(String[] args) {
   /*
   * Creating an Scanner class object which is used to get the inputs
   * entered by the user
   */
   Scanner sc = new Scanner(System.in);
   int choice;
do
{
 System.out.println("\n::MENU::");
   System.out.println("1.Echo Name");
   System.out.println("2.Double Your Age");
   System.out.println("3.Check Teenager or not");
   System.out.println("4.Display Triangle");
   System.out.println("5.Exit");
   System.out.print("Enter Choice:");
   choice = sc.nextInt();
   switch (choice) {
   case 1: {
     System.out.print("Enter your name");
     String name=sc.nextLine();
     for(int i=1;i<=20;i++)
     {
       System.out.println(name);
     }
     break;
   }
   case 2: {
     int age;
     System.out.print("Enter age :");
     age=sc.nextInt();
     System.out.println("Your age :"+age);
     System.out.println("Doubled age :"+(2*age));
    Â
    Â
    Â
     break;
   }
   case 3: {
     int age;
     System.out.print("Enter age :");
     age=sc.nextInt();
    Â
     if(age>=13 && age<=19)
     {
       System.out.println("Since you are "+age+" years old.Your are a Teenager");
     }
     else
     {
       System.out.println("Since you are "+age+" years old.Your are not a Teenager");
     }
     break;
   }
   case 4: {
     int rows;
     do
     {
     System.out.print("Enter a number (between 3 and 50):");
     rows=sc.nextInt();
     if(rows<3 || rows>50)
     {
       System.out.println("** Invalid.Must be between 3 and 50 **");
     }
     }while(rows<3 || rows>50);
     printTriangle(rows);
     break;
   }
   case 5:{
     break;
   }
   default: {
     System.out.println("** Invalid Choice **");
     break;
   }
   } Â
}while(choice!=5);
  Â
 }
 private static void printTriangle(int size) {
   char ch='*';
   for (int a = 0; a < 2 * size - 1; a++) {
     if (a % 2 == 0) {
       for (int b = 0; b < (2 * size - 1) - a; b++) {
         System.out.print(" ");
       }
       for (int c = 0; c <= a; c++) {
         System.out.print(ch+" ");
       }
       System.out.println();
     }
   }
  Â
 }
}
___________________________
Output:
::MENU::
1.Echo Name
2.Double Your Age
3.Check Teenager or not
4.Display Triangle
5.Exit
Enter Choice:1
Enter your name: Mirian
Mirian
Mirian
Mirian
Mirian
Mirian
Mirian
Mirian
Mirian
Mirian
Mirian
Mirian
Mirian
Mirian
Mirian
Mirian
Mirian
Mirian
Mirian
Mirian
Mirian
::MENU::
1.Echo Name
2.Double Your Age
3.Check Teenager or not
4.Display Triangle
5.Exit
Enter Choice:2
Enter age :23
Your age :23
Doubled age :46
::MENU::
1.Echo Name
2.Double Your Age
3.Check Teenager or not
4.Display Triangle
5.Exit
Enter Choice:3
Enter age :16
Since you are 16 years old.Your are a Teenager
::MENU::
1.Echo Name
2.Double Your Age
3.Check Teenager or not
4.Display Triangle
5.Exit
Enter Choice:4
Enter a number (between 3 and 50):6
*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
* * * * * * * * * * *
::MENU::
1.Echo Name
2.Double Your Age
3.Check Teenager or not
4.Display Triangle
5.Exit
Enter Choice:5