Answer to Question #260730 in Java | JSP | JSF for M Uzair

Question #260730

1.     Exercise 2: Create a class building that has the public member floors,area, and occupants and a method areaperperson()respectively that display the area per person for building. In the main() method create two instance of building called house and office and display the area per person by division of area/occupants


1
Expert's answer
2021-11-03T11:45:31-0400


package building;




public class Building {
    public int floors,area,occupants;
    public void areaperperson(){
        System.out.println("Area per person is: \n"+area/occupants);
    }
    
    public static void main(String[] args) {
        Building house = new Building();
        Building office = new Building();
        house.area = 40;
        house.occupants = 5;
        house.areaperperson();
        
        
        office.area = 80;
        office.occupants = 2;
        office.areaperperson();
        
        
    }
    
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS