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 in the user's first and last name on a single line
- Read the user's age in as an integer
- Read the user's campus ID as a string
- Read the user's GPA as a double
<Last Name>, <First Name>
<First Name> is <age>
<First Name>’s GPA is <GPA>
<First Name>'s Campus ID is <CampusID>
For example, your output should look like the following:
Enter Name (First Last): Peter Griffin Enter age: 42 Enter campus ID: AB01234 Enter GPA: 1.23 Your input: Griffin, Peter Peter is 42 Peter’s GPA is 4.00 Peter’s Campus ID is AB01234
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 ScannerInput
{
// 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 the user to enter his first and last name
// The names should be on a single line separated by a space
// First Last
// Prompt the user to enter his age (in words)
// Display the names in the format
// Last, First, Age
}
}