I am curious as to what the error java.util.InputMismatchException means and why I am getting it. This program is the driver class for a file called Dog.java that takes a dog's info and stores it as a string. This file is what directly takes the info and later prints the information out.
The data I am putting in is:
Disco Bandito
4
Sally Struthers
5
Moosen
87
Here is my Code:
import java.util.Scanner;
public class Kennel {
public static void main(String[] args) {
String value1 = null;
int value2 = 0;
String value3 = null;
int value4 = 0;
String value5 = null;
int value6 = 0;
//takes the input from a text file
Scanner scanner = new Scanner(System.in);
while (scanner.hasNextLine()){
value1 = scanner.nextLine();
value2 = scanner.nextInt();
value3 = scanner.nextLine();
value4 = scanner.nextInt();
value5 = scanner.nextLine();
value6 = scanner.nextInt();
}
//the three "dogs" in a kennel
Dog Dog1 = new Dog();
Dog1.setName(value1);
Dog1.getName();
Dog1.setAge(value2);
Dog1.getAge();
Dog1.toString();
Dog Dog2 = new Dog();
Dog2.setName(value3);
Dog2.getName();
Dog2.setAge(value4);
Dog2.getAge();
Dog2.toString();
Dog Dog3 = new Dog();
Dog3.setName(value5);
Dog3.getName();
Dog3.setAge(value6);
Dog3.getAge();
Dog3.toString();
System.out.println(Dog1.toString());
System.out.println(Dog2.toString());
System.out.println(Dog3.toString());
}
}
Thanks, Jake