Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java program that does the following: Prompts the user for the following information and stores the input in variables of the appropriate types:

Write a Java program that does the following:

Prompts the user for the following information and stores the input in variables of the appropriate types:

Whether the user is currently wearing cowboy boots. Use a boolean variable.

The user's age in years, as a double

The name of a sibling or friend of the user

The age in years of the sibling or friend, as an int

The last four digits of the user's CIN

The first letter of the user's mother's first name. Use a char, not a String.

Prints out the following information, using System.out.println() for the output:

a) The values of each of the variables taken from input in the previous part of the assignment, with reasonable Strings as labels, eg You are 23.25 years old You are not currently wearing cowboy boots

etc. Use the ternary conditional operator to get readable output for boolean values.

b) Whether the user is wearing cowboy or is older than 25.0 years. Use logical OR, not nested if statements.

c) Whether the user is wearing cowboy boots or is older than 25.0. Use nested if statements.

d) Whether the user is wearing cowboy boots and is older than 25.0. Use logical AND, not nested if statements.

e) Whether the user is wearing cowboy boots and is older than 25.0. Use nested if statements.

f) Whether the user is neither wearing cowboy boots nor older than 25.0. Use logical AND and logical NOT.

g) Whether the user either a) is wearing cowboy boots and is older than 25.0 or b) is not wearing cowboy boots and is not older than 25.0. Use logical AND, OR, and NOT.

h) Whether the user's age in years is within 1 year of the age of the sibling/friend. Use Math.abs(), which computes the absolute value of a number; you do not care who is older, only about the magnitude of the difference. the output should be similar to this: You and Sally are more than one year apart in age or You and Sally are not more than one year apart in age

i) Whether the last four digits of the user's CIN, taken as a standalone integer, is evenly divisible by 7

j) Whether the first letter of the user's mother's first name is the same as the first letter of the user's friend/sibling's first name. Use String's charAt() method to get the first character of the sibling/friend's name.

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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions

Question

8. Explain the 5P framework for sports marketing.

Answered: 1 week ago