Question

(JAVA) Programming Assignment 3 There are a number of zoos available to tourists. 1. Create a...

(JAVA) Programming Assignment 3

There are a number of zoos available to tourists.

1. Create a Zoo class. Include data fields such as name of zoo, location, size, fee for the past 12 months, number of visitors recorded for the past 12 months, admission rates per visitor and annual budget. (20 points)

2. Include at least two mutators and two accessors. (15 points)

3. Include one default constructor and one more constructor. (15 points)

4. Write separate instance methods that implement: (30 points) a) return a string representing name of the zoo, the location and type of zoo; b) compute total admission based on admission rates and the number of visitors during the last 12 months; c) compute revenue from fees for the past year and total admission.

5. Create a second class to test your Zoo class. (20 points)

In your second class’s Main method, test your class by creating at least three new objects using the constructors or mutators you’ve created in your Zoo class. Each object will represent a specific zoo. Calculate and print revenue for each zoo.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Zoo.java

public class Zoo{

private String name, location;

private double size, fee, rate, budget;

public Zoo() {

size = 1000;

fee = 10;

rate = 2.5;

budget = 500000;

}

public Zoo(String name, String location, double size, double fee, double rate, double budget, int visitors) {

super();

this.name = name;

this.location = location;

this.size = size;

this.fee = fee;

this.rate = rate;

this.budget = budget;

this.visitors = visitors;

}

public double totalAdmissionCost() {

return visitors * rate;

}

public double totalRevenue() {

double revenue = fee + totalAdmissionCost();

System.out.println("Revenue of the zoo is " + revenue);

return revenue;

}

@Override

public String toString() {

return "Zoo [name=" + name + ", location=" + location + ", size=" + size + ", fee=" + fee + ", rate=" + rate

+ ", budget=" + budget + ", visitors=" + visitors + "]";

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getLocation() {

return location;

}

public void setLocation(String location) {

this.location = location;

}

public double getSize() {

return size;

}

public void setSize(double size) {

this.size = size;

}

public double getFee() {

return fee;

}

public void setFee(double fee) {

this.fee = fee;

}

public double getRate() {

return rate;

}

public void setRate(double rate) {

this.rate = rate;

}

public double getBudget() {

return budget;

}

public void setBudget(double budget) {

this.budget = budget;

}

public int getVisitors() {

return visitors;

}

public void setVisitors(int visitors) {

this.visitors = visitors;

}

private int visitors;

}

Test.java

public class Test{

public static void main(String[] args) {

Zoo zoo1 = new Zoo("Corbett", "India", 25000, 1024, 2.8, 10000, 500);

System.out.println(zoo1);

Zoo zoo2 = new Zoo("RedStone", "UK", 12345, 424, 7.2, 124580, 800);

System.out.println(zoo2);

Zoo zoo3 = new Zoo("Venkara", "USA", 4527, 987, 10, 885000, 987);

System.out.println(zoo3);

}

}

<terminated> Test [Java Application] C:Program Files Javajre1.8.0_401bin\javaw.exe (06-Nov-2018, 8:19:48 AM) Zoo [name-Corbett, location-India, size-25000.0, fee-1824.0, rate-2.8, budget-10000.0, visitors-500] Revenue of the zoo is 2424.0 Zoo [name-Redstone, location«К, Revenue of the zoo is 6184.0 size-12345.0, fee-424.0, rate-7.2, budget-124580.0, visitors-800] Zoo [name-Venkara, location-USA, size-4527.0, fee-987.0, rate-10.0, budget-885000.0, visitors-987] Revenue of the zoo is 10857.0

Please check the code. If you have any doubts comment below and I am happy to help :)

Add a comment
Know the answer?
Add Answer to:
(JAVA) Programming Assignment 3 There are a number of zoos available to tourists. 1. Create a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Programming Language is Java 1. Create a class to describe a car. Include fields like: make,...

    Programming Language is Java 1. Create a class to describe a car. Include fields like: make, model, year and color. Add all the accessors and mutators for these fields. Add a constructor that can initialize the fields. 2. Create a class that will enable you to handle standard mail communication with a customer. Add all accessors and mutators, as well as a constructor. Add a method named fullAddress that will return the address formatted for a standard mail. Add a...

  • Create a class House with the private fields: numberOfUnits of the type int, yearBuilt of the...

    Create a class House with the private fields: numberOfUnits of the type int, yearBuilt of the type int, assessedPrice of the type double. A constructor for this class should have three arguments for initializing these fields. Add accessors and mutators for all fields except a mutator for yearBuilt, and the method toString. Create a class StreetHouse which extends House and has additional fields: streetNumber of the type int, homeowner of the type String, and two neighbors: leftNeighbor and rightNeighbor, both...

  • JAVA :The following are descriptions of classes that you will create. Think of these as service...

    JAVA :The following are descriptions of classes that you will create. Think of these as service providers. They provide a service to who ever want to use them. You will also write a TestClass with a main() method that fully exercises the classes that you create. To exercise a class, make some instances of the class, and call the methods of the class using these objects. Paste in the output from the test program that demonstrates your classes’ functionality. Testing...

  • C++ Lab 9A Inheritance Employee Class Create a project C2010Lab9a; add a source file Lab9a.cpp to...

    C++ Lab 9A Inheritance Employee Class Create a project C2010Lab9a; add a source file Lab9a.cpp to the project. Copy and paste the code is listed below: Design a class named Employee. The class should keep the following information in member variables: Employee name Employee number Hire date // Specification file for the Employee class #ifndef EMPLOYEE_H #define EMPLOYEE_H #include <string> using namespace std; class Employee { private:        // Declare the Employee name string variable here. // Declare the Employee...

  • Please help me with the following question. This is for Java programming. In this assignment you are going to demonstrate the uses of inheritance and polymorphism. You will create an Animals class and...

    Please help me with the following question. This is for Java programming. In this assignment you are going to demonstrate the uses of inheritance and polymorphism. You will create an Animals class and a Zoo class that holds all the animals. You should create a general Animalclass where all other classes are derived from (except for the Zoo class). You should then create general classes such as Mammal, Reptile, and whatever else you choose based off of the Animalclass. For...

  • Using C++, this assignment uses two classes which utilize the concept of aggregation. One class will...

    Using C++, this assignment uses two classes which utilize the concept of aggregation. One class will be called TimeOff. This class makes use of another class called NumDays. Then you will create a driver (main) that will handle the personnel records for a company and generate a report. TimeOff class will keep track of an employee’s sick leave, vacation, and unpaid time off. It will have appropriate constructors and member functions for storing and retrieving data in any of the...

  • Java Programming assignment. 1. Create a class called Square that takes a width parameter in the...

    Java Programming assignment. 1. Create a class called Square that takes a width parameter in the constructor. The Square class should have a draw() method that will draw the square on the screen. Create a class called TestSquare that will take width from the user, create an object of Square, and invoke the draw() method on the square object. Below is a UML diagram for the Square and Rectangle class: 3. Create a zip file that contains your Java programs....

  • Create a java class for an object called Student which contains the following private attributes: a...

    Create a java class for an object called Student which contains the following private attributes: a given name (String), a surname (family name) (String), a student ID number (an 8 digit number, String or int) which does not begin with 0. There should be a constructor that accepts two name parameters (given and family names) and an overloaded constructor accepting two name parameters and a student number. The constructor taking two parameters should assign a random number of 8 digits....

  • Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   and please put comment with code! Problem:2 1. Class Student Create...

    Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   and please put comment with code! Problem:2 1. Class Student Create a "Hello C++! I love CS52" Program 10 points Create a program that simply outputs the text Hello C++!I love CS52" when you run it. This can be done by using cout object in the main function. 2. Create a Class and an Object In the same file as...

  • WRITE JAVA PROGRAM Problem Statement You are required to write a stock price simulator, which simulates...

    WRITE JAVA PROGRAM Problem Statement You are required to write a stock price simulator, which simulates a price change of a stock. When the program runs, it should do the following:  Create a Stock class which must include fields: name, symbol, currentPrice, nextPrice, priceChange, and priceChangePercentage.  The Stock class must have two constructor: a no-argument constructor and a constructor with four parameters that correspond to the four fields. o For the no-argument constructor, set the default value for...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT