代写 Write a function rainfallint that takes an array of int, which represent the daily rainfall amounts as measured by field instrument. The data may contain negative numbers, which are errors in the instrument, and should be ignored. The number 999 indicates the end of the data of interest. The function should return the average as a double of the nonnegative values in the list up to the first 999 if it shows up, or 0 if no data is available.

Write a function rainfallint that takes an array of int, which represent the daily rainfall amounts as measured by field instrument. The data may contain negative numbers, which are errors in the instrument, and should be ignored. The number 999 indicates the end of the data of interest. The function should return the average as a double of the nonnegative values in the list up to the first 999 if it shows up, or 0 if no data is available.
Example:

int data 1, 5, 7, 2, 1, 999, 4;
System.out.printlnrainfalldata;
The code above should print out 3.5, because 1 5 7 1 4 3.5. The 2 is ignored, and since we get to 999 before the final number, it is ignored as well.

Congratulations on your new job as a programmer for Red Woof Inn, the countrys leading pet hotel! Alright, so the chain only has one location, but every business has to start somewhere. Red Woof Inn has asked you to create their checkincheckout system, which will keep track of where the animal guests are staying and which rooms are available. With your help, Red Woof Inn will be the top dog in the animal hostel business in no time.

You need to create four classes in total: three which represent animals, and one which represents the hotel. The rooms in the pet hotels are simply numbered 0, 1, 2, and so on, up to however many rooms exist. Pets can checkIn and checkOut of the hotel, and staff can also look up who occupies which room and which pet is staying where.

You must implement the following public methods in the Pet class:

PetString species, String name The constructor. The two arguments are the species and name of the pet, respectively.

String getSpecies Returns the species of the pet.

String getName Returns the name of the pet.

String makeSound Returns I love the Beach Boys!.

boolean equalsPet other Returns true if two pets are the same, false otherwise. For the purpose of this problem, two pets are the same if they are the same species and have the same name.

Additionally, you must create two subclasses of Pet: Duck and Goose. Their species should be duck and goose respectively, and have constructors with only one argument DuckString name and GooseString name. Finally, they should override the makeSound function to return quack! and honk!.

Finally, you must implement the following public methods in the PetHotel class:

PetHotelint size The constructor. The single argument gives the number of rooms in this hotel.

int numRoomsAvailable Gets the number of unoccupied rooms in this hotel.

boolean checkInPet pet Checks in a pet. A pet will always get the empty room with the lowest room number. This function returns true if there is an empty room for the pet, false otherwise.

boolean checkOutPet pet Checks out a pet. The room that was occupied by this pet becomes empty. This function returns true if the pet is staying at the hotel and so can successfully check out, and returns false otherwise.

Pet getOccupantOfint roomNumber Gets the occupant of a particular room. If an invalid roomNumber is given, this function should return null.

You should add member variables to these classes as necessary to store data. We have provided a main function in the PetHotel class that demonstrates how these methods might be used. A correct implementation of these classes should give the return values provided in the comments.