Using Console I/O
In this program, you will use the Scanner
class and
System.out
object to perform console I/O. In the main method,
you will:
- Read the user's first and last name
- Read the user's social security number as an three integers separated by hyphens
- Display the following: the user's name in the format lastname, firstname, followed by the the user's social in the format ddddddddd.
You can copy the following class skeleton into a new class file to start with.
// Import the Scanner class from the Java library here. public class Lab2 { // Declare a Scanner reference variable and create // a Scanner object here. // Note that this reference will have class scope. public static void main( String[ ] args) { // Prompt for and read in the user's first name // Prompt for and read in the user's last name // Note that the user's last name may contain spaces. // Prompt for the user's social in the format // ddd-dd-dddd and read in three integers. // Display the user's name and social in the format // "lastname, firstname: ddddddddd" . } }