For debugging if you change all your datatypes to String
and change the code to something like this
String petname = read.nextLine();
System.out.println("Petname: " + petname);
String birthday = read.next();
String species = read.next();
String bill = read.next();
String owner = read.next();
System.out.println("BirthDay" + birthday);
System.out.println("Name"+petname);
System.out.println("BIll" + bill);
System.out.println("Speci" + species);
System.out.println("Owner " + owner);
You should get an output like
Petname:
BirthDayhopper
Name
BIllkangaroo
Speci2003
Owner 555
That means your birthday is a string but you are trying to store as an int.. Thats why its giving the exception. If you change the code to following
if (read.hasNext()) {
//if prevents NoSuchElementException
String petname = read.next();
System.out.println("Petname: " + petname);
int birthday = read.nextInt();
String species = read.next();
double bill = read.nextDouble();
String owner = read.next();
System.out.println("BirthDay" + birthday);
System.out.println("Name" + petname);
System.out.println("BIll" + bill);
System.out.println("Speci" + species);
System.out.println("Owner " + owner);
}
You get the desired output and the datatypes you wanted.