Answer to Question #239835 in Java | JSP | JSF for doeboy

Question #239835
Your application must make use of concepts such as arrays, loops, inheritance, constructors
and information hiding. Output must be shown in the form of a report using the console.
In your solution, make use of as many concepts, and components dealt with in this course, but
pay special attention to the following learning units:
• Learning Unit 1: Advanced arrays.
• Learning Unit 2: Introduction to inheritance
1
Expert's answer
2021-09-21T01:46:55-0400


package school;
import java.util.Scanner;


public class School {
private int [] departments;
private int number_of_departments;
School(int max){
    number_of_departments = max;
    departments = new int[number_of_departments];
}
    
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        Staff [] f = new Staff[2];
        System.out.println("Enter staffs details\n");
        for(int i=0; i<2; i++){
            System.out.println("Staff "+(i+1));
            System.out.println("ID: \n");
            int id=scan.nextInt();
            System.out.println("Name: \n");
            String name = scan.next();
            f[i].setStaff(id, name);
        }
        
        System.out.println("Staff Details as follows:  \n");
        for(int i=0; i<2; i++){
            System.out.println("Staff:\n "+(i+1));
            System.out.printf("ID: %d\nName:  %s\n ", f[i].getStaffID(), f[i].getName());
        }
    }
    
}


class Staff extends School{
    private int staff_id;
    private String name;
    Staff(int max){
        super(max);
    }
    void Staff(int id, String n){
        staff_id = id;
        name = n;
    }
    int getStaffID(){
        return staff_id;
    }
    String getName(){
        return name;
    }
}

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