Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.Scanner; import javax.swing.*; public class p2 { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner keyboard=new

import java.util.Scanner; import javax.swing.*;

public class p2 { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner keyboard=new Scanner(System.in); Employee[] employee=new Employee[100]; double avg; double sum= 0.0; int count; String c = JOptionPane.showInputDialog(null, "Enter the number of records: "); count= Integer.parseInt(c); String name,ssn; double salary; for(int i=0;i

class Person { String name; Person() { name = "No name yet"; } public Person(String initialName) { name = initialName; } public void setName(String newName) { name = newName; } public String getName() { return name; } public void writeOutput() { JOptionPane.showMessageDialog(null, "Name: " + name); } public boolean hasSameName(Person otherPerson) { return this.name.equalsIgnoreCase(otherPerson.name); } }

class Employee extends Person{ String SSN; double salary; Employee(){ super(); SSN=""; salary=0.0; } public Employee(String nam,String sn,double sal){ super(nam); setSSN(sn); salary=sal; } public void setSSN(String sn){ int count=0; for(int i=0;i'9' || sn.charAt(i)<'0')){ if(sn.charAt(i) !=' ' && sn.charAt(i)!='-') throw new SSNCharacterException(); } } SSN = sn; } } catch(Exception ex){System.out.println(ex.getMessage());} SSN=sn; } public void setSalary(double sal){ salary=sal; } public String getSSN(){ return SSN; } public double getSalary(){ return salary; } public void writeOutput(){ super.writeOutput(); JOptionPane.showMessageDialog(null, "SSN: " + SSN + " Salary: " + salary); } }

class SSNLengthException extends Exception{ public SSNLengthException(){ JOptionPane.showMessageDialog(null, "Not valid length"); } public SSNLengthException(String ms){ super(ms); } }

class SSNCharacterException extends Exception{ public SSNCharacterException(){ JOptionPane.showMessageDialog(null, "Not digit"); } public SSNCharacterException(String ms){ super(ms); } }

I have the program output every thing in dialog box, but i didnt want it to be output Name, SSN, SALARY,Below or Above average on a seperate dialog box for each. i been playing around and i cant get them all to output in one dialog box like

Below or above average

Name

SSN

Salary

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

More Books

Students also viewed these Databases questions

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago