Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Jgrasp make copies of the Employee.java and EmployeeData.java files from lesson 7 to enhance them for this project. Instead of printing each Employees data

In Jgrasp make copies of the Employee.java and EmployeeData.java files from lesson 7 to enhance them for this project. Instead of printing each Employees data after it is entered, load the object to an array of Employee objects containing the data input by the user. At the end of the EmployeeData program use a for loop to print a list of all the Employee objects information after all have been input.

//class Employee.java public class Employee

{

public static void main(String[] args)

{ EmployeeData emp=new EmployeeData(); emp.InputData();

}

}

//EmployeeData.java import java.util.*;

public class EmployeeData

{

//variables

private String FirstName;

private String LastName;

private int empId; private double wages;

private String a;

//constructor

public EmployeeData()

{

//values

this.FirstName=FirstName;

this.LastName=LastName;

this.empId=empId;

this.wages=wages;

}

//method to get input

public void InputData()

{

//creates instance for scanner

Scanner inp = new Scanner(System.in);

//do loop

do

{

//gets the user input

System.out.println("Please enter the employee's data separated by exactly one space first name, last name, numeric ID and hourly wage:");

//get the first name

FirstName =inp.next();

//get the last name

LastName=inp.next();

//get the empid

empId =inp.nextInt();

//get the wages

wages =inp.nextDouble();

displayInformation();

//do wish to continue message

System.out.println("Continue(Yes/No)");

a=inp.next();

//while loop

}while(a.equalsIgnoreCase("yes"));

}

//defines to display

public void displayInformation()

{

//statement to print

System.out.println("EmployeeName:"+FirstName+LastName);

System.out.println("ID:"+empId);

System.out.println("Hourly Wage:"+wages);

}

}

Thank you will upvote!

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

Learn To Program Databases With Visual Basic 6

Authors: John Smiley

1st Edition

1902745035, 978-1902745039

More Books

Students also viewed these Databases questions