Question: JAVA ProgThree should read information about animals, pets and zoo animals. Initial data about pets is available in a text file named animal.txt. The program

JAVA

ProgThree should read information about animals, pets and zoo animals. Initial data about pets is available in a text file named animal.txt. The program should read one line of input from the text file and process it independently. The program should continue until all lines of the input file have been processed.

The input file will contain a single line of data about each animal, pet or zoo animal. There are several lines in the input file and the animals, pets and zoo animals are mixed together. A input line will either contain three or five pieces of data. An input line with three pieces of data is an animal, and those three pieces of data will be animal id, type and weight, in order. Pets and zoo animals have the same first three pieces of data and then two additional pieces of data. If the animal id is between 3,000 and 7,999 the input record is about a pet and the last two pieces of data are the pets name and the owners name, both strings. If the animal id is between 8,000 and 9,999 the input record is about a zoo animal and the last two pieces of data are the cage number, an integer and the trainers name, a string.

The rules for valid input records, follow:

The first piece of data is animalID. It must be a four digit positive integer. Records whose ID numbers are between 3,000 and 7,999 should contain data about a pet. Records whose ID numbers are between 8,000 and 9,999 should contain data about a zoo animal. Records whose ID numbers are between 1,000 and 2,999 should contain data about an animal. Records whose ID numbers are less than 1,000 or greater than 9,999 should be considered to be invalid records.

animalType must be a string of at least three characters.

weight must be a valid positive real number.

For Pet objects, name and owner each must be strings of at least three characters.

For Zoo Animal objects, cageNumber must be a positive integer and trainer must be a string of at least three characters.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!