In: Computer Science
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
//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