1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Varvara68 [4.7K]
4 years ago
6

Your assignment is to write a menu driven program. The menu will be responded to using a switch statement. The menu options (cas

es) will be as follows (You should give them more succinct labels in your program): Read the user’s first name and echo it back out 20 times. Read the user’s age and double it and display the age and the doubled age. Read the user's age and output one of the following statements: Since you are xx years old, you are a teenager Since you are xx years old, you are NOT a teenager (***of course xx displays the user's age) Read a single integer between 3 and 50 from the user. Create a triangle of X’s with the as many rows as the value of the user's input. The triangle needs to be displayed on the screen and in a text document named triangle.txt.
Engineering
1 answer:
lord [1]4 years ago
3 0

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

You might be interested in
Select all that apply.
garik1379 [7]

uhh , not all girls are like that. many of em these days are more career oriented and thats good i guess , so if anything ur just being judgy a f here.

5 0
3 years ago
Precast double-tee units are generally used as structural floors when:________.
TiliK225 [7]

Answer:

<em>d. floor spans exceed that which is economical with site-cast or hollow-core slabs and exceed 60 feet.</em>

<em></em>

Explanation:

<em> Double tee slabs are prestressed concrete castings usually about 100 m to 150 m long</em>. <em>They are usually used in the construction industry in structures requiring a long floor span (or roof span) exceeding 60 feet in length, that is required to bear additional load (additional load carrying capability</em>). Double tee slabs are usually employed in construction because they shorten construction time. reduce congestion at the construction site, and also reduce construction cost.

<em>They are the required choice in construction when the cost of site casting or hollow-core slabs is no longer economical due to the length of the structure exceeding 60 feet.</em>

8 0
3 years ago
Explain your own understanding about the relevant connections between the four subsystems of Earth through the use of a creative
Alex17521 [72]

Answer:

Because these subsystems interact with each other and the biosphere, they work together to influence the climate and make an affect on life all over the Earth.

8 0
3 years ago
What are the main differences between structured,<br> O-O, and agile development methods?
fgiga [73]

Answer:While structured analysis sees procedures and information as isolated segments, object-oriented (O-O) analysis joins information and the procedures that follow up on the information into things called objects. O-O analysis utilizes protest models to show information, conduct, and by what implies objects influence different articles. By portraying the items (information) and techniques (forms) expected to help a business task, a framework engineer can outline reusable segments for quicker framework usage and diminished advancement cost.Numerous experts trust that, contrasted and organized examination, O-O strategies are more adaptable, effective, and reasonable in the present unique business environment. Agile improvement techniques have pulled in a wide after and a whole network of clients.

Agile  strategies ordinarily utilize a winding model, which speaks to a progression of cycles, or revisions,which depend on client criticism. Advocates of the winding model trust that this approach lessens dangers and accelerates programming advancement. Investigators ought to perceive that lithe techniques have points of interest and hindrances. By their tendency, dexterous strategies enable designers to be considerably more adaptable and responsive, however can be less secure than more customary techniques.For instance, without a point by point set of framework necessities, certain highlights asked for by a few clients won't not be predictable with the organization's bigger course of action. Other potential disservices of versatile strategies can incorporate feeble documentation, obscured lines of responsibility, and too little accentuation on the bigger business picture. Additionally, except if legitimately executed, a long arrangement of emphases may really add to extend cost and advancement time.

4 0
3 years ago
Engine oil flows through a 25‐mm‐diameter tube at a rate of 0.5 kg/s. The oil enters the tube at a temperature of 25°C, while th
Elodia [21]

Answer:

a) the log mean temperature difference (Approx. 64.5 deg C)

b) the rate of heat addition into the oil.

The above have been solved for in the below workings

Explanation:

3 0
4 years ago
Other questions:
  • You are designing a system for a real-time application in which specific deadlines must be met. Finishing the computation faster
    10·1 answer
  • Suggest a data structure that supports the following operations on the grades that a student at the university receives. Assume
    5·1 answer
  • Guys i need help and some ones please help me
    12·1 answer
  • The water depths upstream and downstream of a hydraulic jump is 0.3 m and 1.2 m. Determine flow rate
    9·1 answer
  • When a retaining structure moves towards the soil backfill, the stress condition is called:__________.
    8·1 answer
  • 1. ¿Cómo esta simbolizada la Cena en el Antiguo testamento?
    11·1 answer
  • Atoms contain charged particles called___?
    6·1 answer
  • Help!!
    15·2 answers
  • Visual perception is a mental process that is non selective<br> True<br> False
    14·1 answer
  • Describe why the scenario below fails to meet the criteria for proper reverse engineering.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!