Question: For this assignment, you will use the built - in String and Scanner classes of Java to do some simple String manipulations. Download the given

For this assignment, you will use the built-in String and Scanner classes of Java to do
some simple String manipulations.
Download the given Java source code file Program02.java. This file contains the stubs
of five methods. You must write the appropriate code to fill-in each of these five methods,
which are described below. The main method will call each of these five methods, in turn. You
can comment out all but one of these calls while you develop the code for that one method.
phoneNumber()
This method should prompt the user to type in a 10-digit phone number, such as
5056614265. Your method should read in this value as a String (not an int). Your
method should output the phone number using the common dash notation. For
example, the phone number above should be displayed as:
(505)661-4265
Note there is a blank space after the ) symbol. Your method is not required to do any
error checking. We assume that the user will type in exactly 10 digits.
formatNameCase()
This method should prompt the user to enter their first name, and then prompt the user
again to enter their last name. That is, your program should read in two String values.
For example, the user might enter JohN and doE. Your method should output a
greeting to the user, where the first letter of each name is a capital letter, and the
remaining letters are lowercase. For example, your output for the name above should be:
Nice to meet you John Doe
Your method is not required to do any error checking. We assume that the user will type
in alphabetic letters, and not any other symbols.
formatNameOrder()
This method should prompt the user to type in their full name (on a single line) in the
format: FirstName MiddeInitial LastName. For example, the user might enter Jane Q.
Citizen. Note that the user must enter a dot (period) after the middle initial.
Your method should output a greeting to the user, where the format of the name is
changed to put the last name first. For example, the output corresponding to the example
above would be (note the inclusion of a comma):
Nice to meet you Citizen, Jane Q.
Your method is not required to do any error checking. We assume that the user will type
in valid input.
shortenName()
This method should prompt the user to type in their full name (on a single line) in the
format: FirstName MiddleName LastName. For example, the user might enter John
Quincy Adams.
Your method should output a greeting to the user, where the format of the name is
changed so that both the first name and the middle name are only the initial (including the
period). For example, the output corresponding to the example above would be:
Nimport java.util.Scanner;
public class Project2
{
public static void main( String[] args ){
System.out.println ( "Hello world" );
// You can test each of the different
// methods by un-commenting the method name below
// that is, remove the slash-slash
phoneNumber();
// formatNameCase();
// formatNameOrder();
// shortenName();
// checkProtection();
System.out.println( "Good-bye" );
}
public static void phoneNumber()
{
System.out.println( "Delete these System.out statements and");
System.out.println( "replace them with code ");
System.out.println( "that will ask the user ");
System.out.println("to type in 10 digits, and then");
System.out.println( "output the phone number in the");
System.out.println( "correct format");
}
public static void formatNameCase()
{
}
public static void formatNameOrder()
{
}
public static voidice to meet you J. Q. Adams
Your method is not required to do any error checking. We assume that the user will type
in valid input.
checkProtection()
Computers are frequently used in check-writing systems, such as payroll. The check-
writing system may have a limit on the amount of the check. For this problem, we will
assume that limit is $999.99, i.e. there are at most 5 digits in the amount. Smaller
amounts are also legal, such as:
$ 5.21
Notice that the dollar sign always appears on the far left, followed by three locations,
followed by a dot, followed by two locations. It is possible for a person to commit fraud
by writing in a value in the blank spaces above, changing $ 5.21 to $ 45.21.
To prevent this fraud, payroll systems automatically add asterisks (stars) in any blank
spaces between the dollar sign and the leftmost digit. For example, the amount above
would be printed as:
$**5.21
Your method should prompt the user to type in a monetary amount as a floating-point
number (not as a String). This value should not be larger than 999.99. Your method
should output that monetary amount in the fraud protection format described above. If
the input value has more than two digits to the right of the decimal point, then the faction
of a cent should be truncated and ignored.

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!