Answer to Question #246181 in Java | JSP | JSF for Aubrey Eso Jozela

Question #246181
Code a method problemlab(). This method has no parameters and is void. This method displays all computer labs that have less working computers that number of seats. Use the methods problemVenue() and show() coded in question 2. Expected output (take note of headings and other formatting): Problem computer labs Building name: Engineering Venue number: 1.35 Number of seats: 50 Number of working computers: 30 ------------------------- Building name: Engineering Venue number: 1.24 Number of seats: 40 Number of working computers: 35 -------------------------
1
Expert's answer
2021-10-06T04:04:26-0400


package computerlab;


import java.util.Scanner;
public class ComputerLab {
private String building_name;
private int room_number;
private int number_of_seats;
private int working_computers;
ComputerLab(){
    
}
   ComputerLab(String b, int r, int n, int w){
       building_name = b;
       room_number = r;
       number_of_seats = n;
       working_computers = w;
       
   }
    
    ComputerLab createComputerLab(){
        Scanner scan = new Scanner(System.in);
        System.out.println("Enter building name");
        String b = scan.next();
        System.out.println("Enter room number");
        int r = scan.nextInt();
        System.out.println("Enter  number of working computers ");
        int w = scan.nextInt();
        System.out.println("Enter  number of seats ");
        int n = scan.nextInt();
        ComputerLab lab = new ComputerLab(b,  r, n,  w);
        return lab;
    }
    
    public void show(){
      System.out.printf("Building Name: %s\nRoom number: %d\n",  building_name,room_number);
      System.out.printf("Number of seats: %d\nWorking Computers: %d\n",  number_of_seats,working_computers);
    }
    void displayAllRooms(){
      ComputerLab [] lab = new ComputerLab[2];
       System.out.println("Applications Development Foundations:");
      for(int i=0; i<2; i++){
          ComputerLab compute  = new ComputerLab();
          lab[i]  =  compute.createComputerLab();
      }
      for(int i=0; i<2; i++){
          lab[i].show();
          lab[i].problemlab();
      }
    }
    //Answer to the question
    void problemlab(){
        if(number_of_seats > working_computers){
            System.out.println("Problem computer labs  :");
            show();
            System.out.println("------------------------------------------");
        }
    }
    public static void main(String[] args) {
       ComputerLab lab = new ComputerLab();
       lab.displayAllRooms();
    }
    
}

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