Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write an application called IfPractice. It will have a main method. There is no starter code file. In the main method: do the following: Ask

Write an application called IfPractice. It will have a main method. There is no starter code file.

In the main method: do the following:

  1. Ask the user for her/his full name using this prompt: System.out.print("Enter your full name: ");
  2. Print Hello, name! where name is the name that was entered.
  3. Get just the first name. If the full name has a space, then the substring before the first space is the first name; otherwise, take the full name as the first name.
  4. Print: I think I will call you nickname. where nickname is the nickname in the table below.
    First Name Nickname
    James or james Jim
    Robert or robert Bobby
    Ashwani or ashwani Ash
    Any other name Buddy
  5. Prompt the user for her/his age. Prompt with System.out.print("How old are you? ");
  6. Get the age
  7. Based on the age, print one of the messages in the table followed by a comma, a space, and the nickname followed by a period. Example: You are a child, Jim.
    This age and over Under Message
    0 18 You are a child
    18 21 You can vote, but you can not drink
    21 65 You are a full adult
    65 You can get Social Security
  8. Print Goodbye, name! where name is the original name that was entered.

Notes:

  • Use the proper if structure.
  • Do not use do nothing if or else clauses.
  • Do not do unnecessary tests in the if clause. For example this is incorrect: if (age < 18) . . . else if (age >= 18 && age < 21) Leave out the age >= 18. It HAS to be true because you have just determined that age < 18 is false.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Nested Relations And Complex Objects In Databases Lncs 361

Authors: Serge Abiteboul ,Patrick C. Fischer ,Hans-Jorg Schek

1st Edition

3540511717, 978-3540511717

More Books

Students also viewed these Databases questions

Question

2. Outline the business case for a diverse workforce.

Answered: 1 week ago