Page 275 - Introduction to Programming with Java: A Problem Solving Approach
P. 275
}
{
}
String name;
// Instantiate StudentId object and assign it to student.
<insert-code-here>
System.out.print("Enter student name: ");
name = stdIn.nextLine();
// Assign name to the student object.
<insert-code-here>
System.out.print("Enter student id: ");
// In a single line, read an int for the id value,
// and assign it to the student object.
<insert-code-here>
// If invalid id, execute the loop.
// (Use the isValid method in the while loop condition.)
while (<insert-code-here>) {
System.out.print("Invalid student id - reenter: ");
// In a single line, read an int for the id value
// and assign it to the student object.
<insert-code-here>
}
Apago PDF Enhancer
System.out.println("\n" + name +
", your new e-mail account is: \n" +
<insert-code-here> // end main
// Get email account.
} // end class StudentIdDriver
public class StudentId
{
private String name;
private int id;
//*********************************************************
public void setName(String n)
this.name = n;
public String getName()
{
}
return this.name;
Exercises 241