}
Code Screenshots:
XXXX for Employee.java
//Class: Employee public XXXXX XXXXXXXX XXXXXXX Person{ //private XXXXXX private double salary; private XXXXXX telephoneNumber; //constructors XXXXXX Employee() { XXXXX(); }
XXXXXX Employee(String XXXXXXXXXXX) { super(initialName); }
XXXXXX XXXXXXXX(double salary, String telephoneNumber) throws XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX, TelephoneNumberLengthException { super(); XXXX.salary = salary; XXXXXXXXXXXXXXXXXX(XXXXXXXXXXXXXXX); } public XXXXXXXX(XXXXXX XXXX, XXXXXX XXXXXX, XXXXXX telephoneNumber) throws TelephoneNumberCharacterException, TelephoneNumberLengthException { super(XXXX); this.XXXXXX = salary; setTelephoneNumber(XXXXXXXXXXXXXXX); }
//getters XXX XXXXXXX XXXXXX XXXXXX XXXXXXXXX() { return salary; }
public XXXX XXXXXXXXX(XXXXXX salary) { this.XXXXXX = XXXXXX; }
XXXXXX String getTelephoneNumber() { return XXXXXXXXXXXXXXX; } //XXXXXXXXXXXX XXXXXX public void setTelephoneNumber(String telephoneNumber) throws TelephoneNumberCharacterException,TelephoneNumberLengthException { String XXXXXXXXXX = telephoneNumber; //replace - and XXXXX XXXX "" if(tempTelNum!=null){ tempTelNum = tempTelNum.replace("-", ""); XXXXXXXXXX = tempTelNum.replace(" ", ""); } //XXXXX XX all characters of XXXXXXXXX XXX digit or XXX for(char ch: XXXXXXXXXX.XXXXXXXXXXX()){ XX(!Character.XXXXXXX(ch)){ throw new XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX("Character in XXXXXXXXX number XX XXX a XXXXX."); } } //XXXXX XX XXXXXXXXX XXXXXX is XX XX digit if(tempTelNum.XXXXXX()!=XX){ XXXXX new XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX("Telephone XXXXXX XX XXX of 10 XXXXX."); } //XXX telephone number XXXX.telephoneNumber = XXXXXXXXXX; }
@XXXXXXXX public String toString() { return "XXXX = " + XXXXXXX() +", salary=" + XXXXXX + ", telephoneNumber=" + XXXXXXXXXXXXXXX ; } /** * Returns if XXXXXXXX XXXXX is below XXX salary * @param avgSalary * @XXXXXX */ public boolean XXXXXXXXXXXXXX(double avgSalary){ if(this.XXXXXX &XX; XXXXXXXXX) return true; return false; } }
XXXX XXXXXXXXXXX:
XXXX for XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.XXXX
//TelephoneNumberCharacterException class XXXXXX XXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX extends XXXXXXXXX{ XXXXXXX XXXXXX XXXXX XXXX serialVersionUID = -XXXXXXXXXXXXXXXXXXXX; public XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX(XXXXXX msg){ XXXXX(XXX); } }
Code XXX TelephoneNumberLengthException.java
//TelephoneNumberLengthException XXXXX XXXXXX class TelephoneNumberLengthException XXXXXXX XXXXXXXXX{ private XXXXXX XXXXX XXXX XXXXXXXXXXXXXXXX = XXXXXXXXXXXXXXXXXXX; XXXXXX TelephoneNumberLengthException(String msg){ XXXXX(msg); } }
XXXX XXX DemoTelephoneNumber_AM.java
XXXXXX XXXX.text.DecimalFormat; XXXXXX XXXX.XXXX.XXXXXXX;
//XXXXXX XXXXX: DemoTelephoneNumber_AM XXXXXX class DemoTelephoneNumber_AM { //mainMethod XXXXXX static XXXX XXXX(XXXXXX[] args) { //employee array with capacity XX XXXXXXX XXX XXXXXXXX XXXX Employee[] emps = new Employee[100]; Scanner sc = XXX Scanner(XXXXXX.in);//create XXXXXXX XXXXXX.out.println("Add XXXXXXXX XXXX:"); XXX sumOfSalary = X;//to XXXX running sum XX salary XXX XXXXXXX = X;//count XXXXX number XX employee XXXXXXX added in XXXXX //XXXXX infinite XXXXX XXXX while(XXXX){ XXXXXX.out.println("XXXX: "); String XXXX = XX.nextLine();//XXXX XXXX Employee e = new Employee(XXXX); XXXXXX.out.println("Salary: "); XXXXXX XXXXXX = XXXXXX.parseDouble(sc.XXXXXXXX());//XXXX XXX parse salary XXXX double e.setSalary(salary); sumOfSalary += salary;//calculate running XXX of salary //XXXX relephone number as XXXX XX it is not XXXXX XX{ XXXXXX.out.println("Telephone: "); String XXX = sc.nextLine(); XXX{ e.setTelephoneNumber(tel); break; }catch(XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX te1){ XXXXXX.out.println(te1.XXXXXXXXXX()+" XXXXXX try again!"); }catch(TelephoneNumberLengthException XXX){ XXXXXX.out.XXXXXXX(XXX.getMessage()+" XXXXXX XXX again!"); } }while(true); emps[counter++] = e;//add employee in array //XXXXX if another XXXXXXXX needs XX be XXXXX in XXXXX or not XXXXXX.out.println("Press X to XXXX or any other key to add XXXXXXX:"); XXXXXX XXXXX = sc.XXXXXXXX(); if(input.XXXXXX("0")){ sc.close(); XXXXX; } } //XXXXXXXXX and print average salary double avgSalary = XXXXXXXXXXX/counter; XXXXXX.out.println("XXXXXXX XXXXXX is = "+ XXX DecimalFormat("#.00").format(avgSalary)); System.out.XXXXXXX(); System.out.XXXXXXX("XXXXXXXX XXXXXXXX XXXX: "); XXXXXX.out.println(); //XXXXX employee XXXX XXX(XXX i = X ;i < counter; i++){ XXXXXXXX e = emps[i]; System.out.XXXXX(e); if(e.isBelowAverage(XXXXXXXXX)){ XXXXXX.out.print(" : Below Average XXXXXX."); }XXXX{ XXXXXX.out.print(" : XXXXX Average Salary."); } System.out.println(); }
Output XXXXXXXXXXX:
Hope it helps. Thank you.