I am using a scanner, and i wanted to make sure that the user was inputting the correct data types. I also wanted to cut down on code reuse. So i have a couple of methods fir the inputs
private String inputString(String prompt) {
System.out.println(prompt);
return input.next();
}
private int inputInt(String prompt) {
int val = -1;
for(;;)
{
System.out.println(prompt);
try {
val = Integer.parseInteger(input.next());
break;
}
catch (Exception ex) {
System.out.println("Invalid value, please try again.");
}
}
return val;
}
public void addUser(int choice)
{
if(choice==1)
{
String title = inputString("Please enter your title ");
int studentId = inputInt("Please enter your Student ID ");
StudentBorrower studentBor = new StudentBorrower(title, studentId);
libraryUsers[x]=studentBor;
x++;
}
The problem at the moment is that i am receiving the error cannot find symbol method Integer.parseInt(java.lang.String)
I am not sure why i am getting this error, do i need to import a library besides scanner? Is someone able to explain why i might be getting this error?
thanks