/* This program creates an array of objects (employee) and displays a comparison graph of employees' salaries. */ import java.util.Scanner; class ArrayRec1 { public static void main (String[] args) { String name; int salary; Scanner scan = new Scanner(System.in); System.out.print ("How many employees work in your company? "); int numemployees = scan.nextInt(); scan.nextLine(); Employee[] staff = new Employee[numemployees]; /* Initialize the staff array */ for (int i = 0; i < staff.length; i++) { staff[i] = new Employee(); } for (int i = 0; i < staff.length; i++) { System.out.print ("Enter employee name: "); name = scan.nextLine(); staff[i].setName(name); System.out.print ("Enter Employee salary: "); salary = scan.nextInt(); scan.nextLine(); staff[i].setSalary(salary); } for (int i = 0; i < staff.length; i++) { staff[i].displaySalary(); } } } class Employee { String emplname; int emplsalary; /* A default constructor whose purpose is to initialize data fields of the Employee object. */ public Employee () { emplname = " "; emplsalary = 0; } void setName (String name) { emplname = name; } void setSalary (int salary) { emplsalary = salary; } void displaySalary () { int normsalary = (int) emplsalary/1000; System.out.println (emplname + "'s salary: "); for (int i = 1; i <= normsalary; i++) { System.out.print("*"); } System.out.flush(); System.out.println(); } }