Question: (JAVA) Decision control structure and concepts related to pre-defined functions and Strings: Assignment: These are 2 unrelated tasks performed in one Java file. Part 1

(JAVA) Decision control structure and concepts related to pre-defined functions and Strings:

Assignment: These are 2 unrelated tasks performed in one Java file.

Part 1 ) Write the code to generate a random number between 5 and 15. Use the switch statement to display OK, if the number is 5 or 6, display GOOD, if the number is 7, and display EXCELLENT, for all other cases.

Part 2 ) Write the code to

Ask the user for any number and display the rounded number. USE the round function. Display the natural logarithm of the number with 5 digits after the decimal point.

Ask the user for a string. If the input string is entered exactly as myjava, display an error message and terminate the program. Any other input is considered to be valid.

If the string input by the user is valid, display the length of the string and the first 3 characters of the string, only if the string has 3 characters or more. Otherwise, display an error message and terminate the program.

If the string input by the user is valid, display the string in upper case, lower case, and display the first and the last character of the string.

Part 1) SAMPLE RUN:

Your generated random number is 7.

Good Part

2) SAMPLE RUN:

Enter any number: 120.88679

Your rounded number is: 121

The natural logarithm of the number is: 4.79480

Enter a String: myjava

Program terminating!

Enter a String: Hello There

Length of the string: 11

The first 3 characters of the string is: hel

Upper case: HELLO WORLD

Lower case; hello world

First character: H

Last character: e

Enter a String: Hi

Program terminating!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!