Question

In: Computer Science

You must create two Java files. One is called LastNameFirstNameWeek6Prog.java, and the other is called  Museum.java. Ensure...

You must create two Java files. One is called LastNameFirstNameWeek6Prog.java, and the other is called  Museum.java.

Ensure you include ALL files required to make your program compile and run. I would like to see your .java files only.

5%

Museum.java Class File

1.    Create a new class called Museum that describes a Museum and includes the functionality below

2.    The new class has the following five attributes:
a. officialName – the museum’s given name (i.e.:“ New Orleans Museum of Arts”,etc.), type String
b. specialty – the museum’s type (i.e.:“Art”, “Science”, etc.), type String
c. numberOfBuildings – the number of buildings in the museum, type integer
d. area – the museum’s area in square feet, type double
e. financed - type boolean - true if the museum is financed by patrons, false if not.
Use these names for attributes exactly as given here. All attributes must be private.

3.    Be sure your classes have a good set of accessor and mutator methods. Every member variable must have at least one independent accessor and one independent mutator. (see document on Program help for examples)

Ensure you use the “this” reference from within this class when referring to every instance variable or instance method of the current object.

45%

LastNameFirstNameWeek6Prog.java Class File (Driver Program)

Write a driver program that reads information from the user about 3 museums and use this info to create 3 respective Museum objects. The following information should be read from the user per Museum:
official name
specialty
number of buildings
area in square feet
is the museum financed?

After this, using the information inside the objects the program, the driver program should evaluate and print the following output:

·        The average area of the three Museums

·        The minimum and maximum number of buildings among all the Museums

·        The name of the financed Museum with the most area.

To get the information from the objects, use accessor methods from the Museum class. Do not use local variables in main for these calculations. You may use local variables to read the information from the user, but once this information is set on the Museum objects, you must use the get methods to retrieve the information from the objects themselves.

Also do not use Arrays or any other advanced concept that was not reviewed in the class to solve this assignment. Assignments that use these concepts will only be graded 10% for presentation.

45%

NOTE: Complete your activity and submit it by clicking on "Submit Assignment".

5%

Total Possible Points

100

Example output of your program

Example Run:

Enter the official name for Museum 1: New Orleans Museum of Arts
Enter the specialty for Museum 1: Art
Enter the number of buildings for Museum 1: 3
Enter the area of the Museum 1 in square feet: 5000
Is Museum 1 financed? true or false?: true

Enter the official name for Museum 2: D-Day Museum
Enter the specialty for Museum 2: History
Enter the number of buildings for Museum 2: 2
Enter the area of the Museum 2 in square feet: 3000
Is Museum 2 financed? true or false?: false

Enter the official name for Museum 3: The Louvre
Enter the specialty for Museum 3: Art
Enter the number of buildings for Museum 3: 25
Enter the area of the Museum 3 in square feet: 100000
Is Museum 3 financed? true or false?: true

The museums average area is 36000.0
The museums minimum number of buildings is: 2
The museums maximum number of buildings is: 25
The financed museum with largest area is: The Louvre with 100000.0 square feet

Solutions

Expert Solution

//Java code

public class Museum {
    /**
     *  officialName – the museum’s
     *  given name (i.e.:“ New Orleans Museum of Arts”,etc.), type String
     */
    private String officialName;
    /**
     *  specialty –
     *  the museum’s type (i.e.:“Art”, “Science”, etc.), type String
     */
    private String speciality;
    /**
     *  numberOfBuildings – the number of buildings in the museum, type integer
     */
    private int numberOfBuildings;
    /**
     * area – the museum’s area in square feet, type double
     */
    private double area;
    /**
     * . financed - type boolean - true if
     * the museum is financed by patrons, false if not.
     */
    private boolean financed;

    //Default Constructor
    public Museum()
    {

    }

    //Parametrised Constructor

    public Museum(String officialName, String speciality, int numberOfBuildings, double area, boolean financed) {
        this.officialName = officialName;
        this.speciality = speciality;
        this.numberOfBuildings = numberOfBuildings;
        this.area = area;
        this.financed = financed;
    }

    //set of accessor and mutator methods.

    public String getOfficialName() {
        return officialName;
    }

    public void setOfficialName(String officialName) {
        this.officialName = officialName;
    }

    public String getSpeciality() {
        return speciality;
    }

    public void setSpeciality(String speciality) {
        this.speciality = speciality;
    }

    public int getNumberOfBuildings() {
        return numberOfBuildings;
    }

    public void setNumberOfBuildings(int numberOfBuildings) {
        this.numberOfBuildings = numberOfBuildings;
    }

    public double getArea() {
        return area;
    }

    public void setArea(double area) {
        this.area = area;
    }

    public boolean isFinanced() {
        return financed;
    }

    public void setFinanced(boolean financed) {
        this.financed = financed;
    }
}

//=============================================

import java.util.Scanner;

public class LastNameFirstNameWeek6Prog {
    public static void main(String[] args)
    {
        Museum newOrleansMuseum = new Museum();
        Scanner keyboard = new Scanner(System.in);
        System.out.print("Enter the official name for Museum 1:");
        newOrleansMuseum.setOfficialName(keyboard.nextLine());
        System.out.print("Enter the speciality for Museum1: ");
        newOrleansMuseum.setSpeciality(keyboard.nextLine());
        System.out.print("Enter the number of buildings for Museum1: ");
        newOrleansMuseum.setNumberOfBuildings(keyboard.nextInt());
        System.out.print("Enter the area of the Museum1 in square feet: ");
        newOrleansMuseum.setArea(keyboard.nextDouble());
        System.out.print("Is Museum 1 financed? true or false?: ");
        newOrleansMuseum.setFinanced(keyboard.nextBoolean());

        //=============================================
        Museum d_day = new Museum();
        keyboard.nextLine();
        System.out.print("Enter the official name for Museum 2:");
        d_day.setOfficialName(keyboard.nextLine());
        System.out.print("Enter the speciality for Museum2: ");
        d_day.setSpeciality(keyboard.nextLine());
        System.out.print("Enter the number of buildings for Museum2: ");
        d_day.setNumberOfBuildings(keyboard.nextInt());
        System.out.print("Enter the area of the Museum2 in square feet: ");
        d_day.setArea(keyboard.nextDouble());
        System.out.print("Is Museum 2 financed? true or false?: ");
        d_day.setFinanced(keyboard.nextBoolean());

        //==============================================
        Museum theLouvre = new Museum();
        keyboard.nextLine();
        System.out.print("Enter the official name for Museum 3:");
        theLouvre.setOfficialName(keyboard.nextLine());
        System.out.print("Enter the speciality for Museum3: ");
        theLouvre.setSpeciality(keyboard.nextLine());
        System.out.print("Enter the number of buildings for Museum3: ");
        theLouvre.setNumberOfBuildings(keyboard.nextInt());
        System.out.print("Enter the area of the Museum3 in square feet: ");
        theLouvre.setArea(keyboard.nextDouble());
        System.out.print("Is Museum 3 financed? true or false?: ");
        theLouvre.setFinanced(keyboard.nextBoolean());

        //Get average
        double avg = (newOrleansMuseum.getArea()+ d_day.getArea()+ theLouvre.getArea())/3.0;
        System.out.println("The museums average area is "+avg);

        //Find minimum building
        int min= newOrleansMuseum.getNumberOfBuildings();
        if(min> d_day.getNumberOfBuildings())
            min = d_day.getNumberOfBuildings();
        if(min> theLouvre.getNumberOfBuildings())
            min = theLouvre.getNumberOfBuildings();

        //Find maximum building
        int max= newOrleansMuseum.getNumberOfBuildings();
        if(max< d_day.getNumberOfBuildings())
            max = d_day.getNumberOfBuildings();
        if(max< theLouvre.getNumberOfBuildings())
            max = theLouvre.getNumberOfBuildings();
        //Find largest area
        double maxArea = newOrleansMuseum.getArea();
        String name = newOrleansMuseum.getOfficialName();
        if(maxArea< d_day.getArea()) {
            maxArea = d_day.getArea();
            name = d_day.getOfficialName();
        }
        if(maxArea< theLouvre.getArea()) {
            maxArea = theLouvre.getArea();
            name = theLouvre.getOfficialName();
        }

        //Output
        System.out.println("The museum minimum number of buildings is: "+min);
        System.out.println("The museums maximum number of buildings is: "+max);
        System.out.println("The financed museums with largest area is: "+name+" with "+maxArea+" square feet.");


    }
}

//Output

//If you need any help regarding this solution .............. please leave a comment ............ thanks


Related Solutions

In Java: (1) Create two files to submit: ItemToBuy.java - Class definition ShoppingCartDriver.java - Contains main()...
In Java: (1) Create two files to submit: ItemToBuy.java - Class definition ShoppingCartDriver.java - Contains main() method Build the ItemToBuy class with the following specifications: Private fields String itemName - Initialized in the nor-arg constructor to "none" int itemPrice - Initialized in default constructor to 0 int itemQuantity - Initialized in default constructor to 0 No-arg Constructor (set the String instance field to "none") Public member methods (mutators & accessors) setName() & getName() setPrice() & getPrice() setQuantity() & getQuantity() toString()...
When using random access files in Java, the programmer is permitted to create files which can...
When using random access files in Java, the programmer is permitted to create files which can be read from and written to random locations. Assume that a file called "integers.dat" contains the following values: 25 8 700 284 63 12 50 Fill in blanks: You are required to write the following Java code statements: (a) create a new stream called, blueray, which allows the program to read from and write to the file, "integers.dat." _____________________ (b) Write a statement which...
Using java, create a class called MyString that has one String called word as its attribute...
Using java, create a class called MyString that has one String called word as its attribute and the following methods: Constructor that accepts a String argument and sets the attribute. Method permute that returns a permuted version of word. For this method, exchange random pairs of letters in the String. To get a good permutation, if the length of the String is n, then perform 2n swaps. Use this in an application called Jumble that prompts the user for a...
9) Create a java programming where you will enter two numbers and create only one method,...
9) Create a java programming where you will enter two numbers and create only one method, which will return or display addition, substraction, multiplication, division, average and check which number is greater than the other. Everything in one method and call it in main method.
JAVA (1) Create two files to submit: Payroll.java - Class definition PayrollClient.java - Contains main() method...
JAVA (1) Create two files to submit: Payroll.java - Class definition PayrollClient.java - Contains main() method Build the Payroll class with the following specifications: 4 private fields String name - Initialized in default constructor to "John Doe" int ID - Initialized in default constructor to 9999 doulbe payRate - Initialized in default constructor to 15.0 doulbe hrWorked - Initialized in default constructor to 40 2 constructors (public) Default constructor A constructor that accepts the employee’s name, ID, and pay rate...
Java Palindrome Use StringBuilder concept to create a palindrome checker.   Method should be called pCheck. Must...
Java Palindrome Use StringBuilder concept to create a palindrome checker.   Method should be called pCheck. Must use var-arg concept.   Class name for this program is Palindrome.   Must pass this test:: public class PalindromeTest { public static void main(String[] args) { Palindrome palindrome = new Palindrome(); boolean answer = palindrome.pCheck("racecar", "Bell", "elle", "bunny"); System.out.println(“These are palindromes: " + answer); } }
C++ Create an ArrayBag template class from scratch. This will require you to create two files:...
C++ Create an ArrayBag template class from scratch. This will require you to create two files: ArrayBag.hpp for the interface and ArrayBag.cpp for the implementation. The ArrayBag class must contain the following protected members: static const int DEFAULT_CAPACITY = 200; // max size of items_ ItemType items_[DEFAULT_CAPACITY]; // items in the array bag int item_count_; // Current count of items in bag /** @param target to be found in items_ @return either the index target in the array items_ or...
Create a new folder called CSCI130_A3_yourname. Create all of the files indicated below within this folder....
Create a new folder called CSCI130_A3_yourname. Create all of the files indicated below within this folder. For this assignment you will be creating a total of 2 classes that meet the definitions below. This assignment will allow the user to enter in the coefficients for a polynomial function of degree 2. The user will then be asked to enter a number. The program will use that number as an argument to the function, and will print the corresponding function value....
You are to create a hard link to one of your existing files on someone else's...
You are to create a hard link to one of your existing files on someone else's directory (or vice versa). In other words, you know that you can link a file within your own directories, but you can also have a link to one of your files on other areas of the unix system as long as you have permissions to write to that directory (in this case, your partner). Create a subdirectory called temp where you can place this...
 In this exercise, you will create two external style sheet files and a web page. You...
 In this exercise, you will create two external style sheet files and a web page. You will experiment with linking the web page to the external style sheets and note how the display of the page is changed. Create an external style sheet (call it format1.css) to format as follows: document background color of white, document text color of #000099, and document font family of Arial, Helvetica, or sans-serif. Hyperlinks should have a background color of gray (#CCCCCC). Configure the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT