Please follow the steps to complete JAVA PROGRAM
- Create a class, EmployeeException, that has the following attributes:
- name: String
- SSN: String
- Salary: double
- The methods required in this class are:
- A constructor with no arguments that sets the attributes at default values
- A constructor that passes values for all attributes
- Accessor, mutator, display method for each attribute. An example of a display method for an attribute is writeOutName(): void, in which you just display the name:
System.out.println("Employee Name: " + name); - An equals method that has an object of type Employee as argument, and returns true if two employees have the same name, salary, and SSN.
- Write a driver program for the Employee class that uses an array that can hold up to 100 employees (the array will be of EmployeeException type). However, the user should be free to enter as many employees as needed.
- The driver class should use two exception classes to signal the user that the SSN entered is not correct. SSN needs to be entered as a 9-digit string without separators. You need to create these two classes:
- SSNStructureException for when any character in the social security number is not a digit.
- SSNLengthException for when the social security number entered, without connection characters (dash, or space), has a length other than nine.
- Download the template file, EmployeeException.txt, and save it as EmployeeException.java
-
public class EmployeeException{
-
//*** Task #1: define the instance variables//
-
*** Task #2: define constructor with no arguments//
-
*** Task #3: define constructor passing values for all arguments//
-
*** Tasks #4: define accessor, mutator, and write out methods for name attribute//
-
*** Tasks #5: define accessor, mutator, and write out methods for sSN attribute// Display the SSN as ddd-dd-dddd//***
-
Tasks #6: define accessor, mutator, and write out methods for salary attribute
//*** Tasks #7: Define method writeOutput() that display all information about the employee.//
-
*** Tasks #8: Define equals method, having argument of type EmployeeException}
-
- Go through the template file and identify the tasks you have to complete, which are clearly marked throughout the file. Complete all the required tasks.
- Download the template file, EmployeeExceptionDriver.txt, and save it as EmployeeExceptionDriver.java.
-
import java.util.Scanner;
-
public class EmployeeExceptionDriver{
-
public static void main(String [] args){
-
//*** Task #1: define the variables required for the program
-
//*** Task #2: define and instantiate variable of type Scanner to be able to read from
-
//*** Task #3: create a loop in which you enter the data for employee.
-
//*** Task #4: inside the loop, instantiate each element of the array with the constructor
-
//*** Task #5: read the name of the employee
-
//*** Task #6: read the salary of the employee
-
//*** Task #7: read SSN using the exceptions blocks
-
//*** Task #8: ask the user if there are more employees to enter
-
//*** Task #9: calculate the average salary
-
//*** Task #10: display the information about all employees with a note if their salary// is above average, under average or average.
-
System.out.println("No more employees.");
-
}}
-
- Compile and execute the files.
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 1 images
Your program only work for one emplyee. For second emplyee I can not enter name of employee. I need for five emplyoee.
Your program only work for one emplyee. For second emplyee I can not enter name of employee. I need for five emplyoee.
- In python, please complete both sections Section 1: The Course class A simple class that stores the id, name, and number of credits for a class. Attributes Type Name Description str cid Stands for course id, uniquely identifies a course like “CMPSC132”. str cname Stands for course name and is the long form of the course title. int credits The number of credits a course is worth. Special methods Type Name Description str __str__(self) Returns a formatted summary of the course as a string. str __repr__(self) Returns the same formatted summary as __str__. bool __eq__(self, other) Does an equality check based only on course id. __str__(self), __repr__(self) Returns a formatted summary of the course as a string. The format to use is: cid(credits): cname Output str Formatted summary of the course. __eq__(self, other) Determines if two objects are equal. For instances of this class, we will define equality when the course id of one object is the same as the course id of the other object.…arrow_forwardQUESTION 7 Final data/code constructs are only inheritable once. O True O False QUESTION 8 You can include code in an interface by using the keywordarrow_forwardC++arrow_forward
- 1. Dummy GUI Application by Codechum Admin A GUI Application is an application that has a user interface that the user can interact with. For this program, we will be simulating this behavior. First, implement another class called Checkbox which implements the Clickable interface which has only one method: public void click(). The Checkbox will have the following properties: private boolean isChecked (defaults to false upon the creation of object) private String text Additionally, it should have the following methods: the implementation of the click() method If the isChecked is currently false, this will set the isChecked to true and will then print the message "Checkbox is checked". If it is currently true, this will set the isChecked to false and will then print the message "Checkbox is unchecked". Note that the messages to be printed should have also print a new line at the end. an override of the toString() method which returns the message: "Checkbox ({text} - Clicked…arrow_forwardjava Assignment Description: Write a class named Car that has the following fields: The yearModel field is an int that holds the car’s year model. The make field references a String object that holds the make of the car. The speed field is an int that holds the car’s current speed. In addition, the class should have the following constructor and other methods. The constructor should accept the car’s year and make as arguments. These values should be assigned to the object’s yearModel and make fields. The constructor should also assign 0 to the speed field. Constructor: The constructor should accept no arguments. Constructor: The constructor should accept the car’s year as argument.Assign the value to the object’s yearModel. No need to assign anything to the make and assign 0 to speed. Appropriate mutator methods should set the values in an object’s yearModel, make, and speed fields. Appropriate accessor methods should get the values stored in an object’s yearModel, make, and…arrow_forwardA class object can encapsulate more than one [answer].arrow_forward
- python code: 1.Create an empty class called Car. 2.Create a method called initialize in the class, which takes a name as input and saves it as a data attribute. 3.Create an instance of the class, and save it in a variable called car. 4.Call the initialize method with the string “Ford".arrow_forwardpublic class ItemToPurchase { private String itemName; private int itemPrice; private int itemQuantity; // Default constructor public ItemToPurchase() { itemName = "none"; itemPrice = 0; itemQuantity = 0; } // Mutator for itemName public void setName(String itemName) { this.itemName = itemName; } // Accessor for itemName public String getName() { return itemName; } // Mutator for itemPrice public void setPrice(int itemPrice) { this.itemPrice = itemPrice; } // Accessor for itemPrice public int getPrice() { return itemPrice; } // Mutator for itemQuantity public void setQuantity(int itemQuantity) { this.itemQuantity = itemQuantity; } // Accessor for itemQuantity public int getQuantity() { return itemQuantity; }} import java.util.Scanner; public class ShoppingCartPrinter { public static void main(String[] args) { Scanner scnr = new…arrow_forwardLab 2 – Designing a class This lab requires you to think about the steps that take place in a program by writing pseudocode. Read the following program prior to completing the lab. Design a class named Computer that holds the make, model, and amount of memory of a computer. Include methods to set the values for each data field, and include a method that displays all the values for each field. For the programming problem, create the pseudocode that defines the class and enter it below. Enter pseudocode herearrow_forward
- Java Programming Please do not change anything in Student class or Course class class John_Smith extends Student{ public John_Smith() { setFirstName("John"); setLastName("Smith"); setEmail("jsmith@jaguar.tamu.edu"); setGender("Male"); setPhoneNumber("(200)00-0000"); setJNumber("J0101459"); } class MyCourse extends Course { public MyCourse { class Course { private String courseNumber; private String courseName; private int creditHrs; public Course (String number, String name, int creditHrs){ this.courseNumber = number; this.courseName = name; this.creditHrs = creditHrs; } public String getNumber() { return courseNumber; } public String getName() { return courseName; } public int getCreditHrs() { return creditHrs; } public void setCourseNumber(String courseNumber) { this.courseNumber = courseNumber; } public void setCourseName(String…arrow_forwardJava prgm basedarrow_forwardPlease help with the following: C# .NET change the main class so that the user is the one that as to put the name a driver class that prompts for the person’s data input, instantiates an object of class HealtProfile and displays the patient’s information from that object by calling the DisplayHealthRecord, method. MAIN CLASS---------------------- static void Main(string[] args) { // instance of patient record with each of the 4 parameters taking in a value HeartRates heartRate = new HeartRates("James", "Kill", 1988, 2021); heartRate.DisplayPatientRecord(); // call the method to display The Patient Record } CLASS HeartRATES------------------- class HeartRates { //class attributes private private string _First_Name; private string _Last_Name; private int _Birth_Year; private int _Current_Year; // Constructor which receives private parameters to initialize variables public HeartRates(string First_Name, string Last_Name, int Birth_Year, int Current_Year) { _First_Name = First_Name;…arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY