Question: Frank is writing code that will allow the user to input an integer and then a string in that order. He has written the following
Frank is writing code that will allow the user to input an integer and then a string in that order. He has written the following statements:
// Input an integer.
System.out.print(Type an integer: );
int anInt = keyboard.nextInt();
// Input a string.
System.out.print(Type a string: );
String aString = keyboard.nextLine();
Will this code operate as he desires? If not, what statement(s) must be added to the code and where? Do not modify Franks statements or change their order in the program.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
