CSC1110 Exercise - Week 2
Overview
This exercise will give you practice with using the Scanner and basic String and Wrapper methods.
Instructions:
Write a program called Exercise2.java that does the following and replicates the output shown below.
- Ask the user for their first name and then for their last name. You should have two separate variables for the first and last name. Create a print statement that prints the last name, a comma, and then the first name as a single line and in that order.
- Ask the user for a value for pi and the radius of a circle. Print out the circle's area.
- Ask the user for a number between 1 and 10. Ask the user for a phrase with spaces that has more than characters than the value they entered. Print out the substring from the beginning of the phrase to, but not including, the number entered by the user. Remember to clear the input buffer with a nextLine() command.
- Ask the user for a letter. Print out true or false depending on if the letter is uppercase or not.
- Ask the user for the time in military format (e.g., 14:45), and the print out the number of minutes left in the hour.
Sample Output
Enter your first name.
Jane
Enter your last name.
Doe
Full name: Doe,Jane
Enter a value for pi.
3.14
Enter the radius of a circle
10
Area: 314.0
Enter a number from 1 to 10.
8
Enter a phrase with spaces, that is more than 8 characters.
Hello World!
The first 8 characters are: Hello Wo
Enter a letter
A
Is the letter uppercase: true
Enter the current time in military format (e.g., 14:45)
15:06
There are 54 minutes left in the hour.
Submission
See your professor's instructions for details on submission guidelines and due dates.