Discount CIS247 CIS 247 CIS/247 - CIS247B - Java Programming - All Week - All Lab - All iLab - Week 1 - Week 2 - Week 3 - Week 4 - Week 5 - Week 6 - Week 7 – Guaranteed 100% score
    CIS247 CIS 247 CIS/247 - CIS247B - Java Programming - All Week - All Lab - All iLab - Week 1 - Week 2 - Week 3 - Week 4 - Week 5 - Week 6 - Week 7 – Guaranteed 100% score CIS247 CIS 247 CIS/247 - CIS247B - Java Programming - All Week - All Lab - All iLab - Week 1 - Week 2 - Week 3 - Week 4 - Week 5 - Week 6 - Week 7 – Guaranteed 100% score CIS247 CIS 247 CIS/247 - CIS247B - Java Programming - All Week - All Lab - All iLab - Week 1 - Week 2 - Week 3 - Week 4 - Week 5 - Week 6 - Week 7 – Guaranteed 100% score

CIS247 CIS 247 CIS/247 - CIS247B - Java Programming - All Week - All Lab - All iLab - Week 1 - Week 2 - Week 3 - Week 4 - Week 5 - Week 6 - Week 7 – Guaranteed 100% score

$84.70
$112.93

CIS247 Week 1 Lab, Design
Program Description: Basic User Interface
This program creates the basic user interface code that can be used in the following week’s iLab assignments. The assignment will help you get started using the programming environment and some practice with coding. You will also be able to re-use much, if not all, of the code in later assignments.
In this program, you will create the following methods:

  1. displayApplicationInformation, which will provide the program user some basic information about the program.
  2. displayDivider, which will provide a meaningful output separator between different sections of the program output.
  3. getInput, which is a generalized function that will prompt the user for a specific type of information, then return the string representation of the user input.
  4. terminateApplication, which provides a program termination message and then terminates the application.

Using these methods, you will construct a program that prompts the user for the following:

  1. Their name, which will be a string data type
  2. Their age, which will be an integer data type
  3. The gas mileage for their car, which will be a double data type
  4. Display the collected information

Also, note that the program should contain a well documented program header.
Pseudocode
//Program Header
//Program Name: Basic User Interface
//Programmer: Your Name
//CIS247, Week 1 Lab
//Program Description: PROVIDE A DESCRIPTION OF THE PROGRAM
Start main
//declare variables
input as string
name as string
age as integer
mileage as double
calldisplayApplicationInformation
calldisplayDivider(“Start Program”)
calldisplayDivider(“Get Name”)
set name = getInput(“Your Name”)
display “Your name is: “ + name
calldisplayDivider(“Get Age”)
set input = getInput(“Your Age”)
set age = convert input to integer
display “Your age is: “ + age
calldisplayDivider(“Get Mileage”)
set input = getInput(“Gas Mileage”)
set mileage = convert input to double
display “Your car MPG is: “ + mileage
callterminateApplication
end main program
proceduredisplayApplicationInformation
display “Welcome the Basic User Interface Program”
display “CIS247, Week 1 Lab”
display “Name: YOUR NAME”
display “This program accepts user input as a string, then makes the appropriate data conversion and displays the results”
end procedure
proceduredisplayDivider(string outputTitle)
display “**************** “ + outputTitle + “****************”
end procedure
functiongetInput(string inputType) as string
strInput as string
display “Enter the “ + inputType
getstrInput
returnstrInput
end function
procedureterminateApplication
display “Thank you for using the Basic User Interface program”
exit application
end procedure

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Week 2: Object Construction and Data Abstraction – iLab

iLab 2 of 7: Employee Class

Connect to the iLab here.

Submit your assignment to the Dropbox located on the silver tab at the top of this page.
(See Syllabus “Due Dates for Assignments & Exams” for due dates.)

i L A B O V E R V I E W

Scenario and Summary
We begin our investigation of object-oriented programming by creating an object-oriented program with a class called Employee. You will create two objects based on the Employee class, along with a class that contains the main method. The attributes, constructors, and methods for this class must satisfy the requirements in Steps 1 through 3. After you create the objects, you will prompt the user for information and then display it.
We will want to ensure that this first class is well-constructed and tested since we will extend this class in Labs 3 through 6.
Deliverables
Due this week:

  • Capture the Console output window and paste it into a Word document.
  • Zip the project folder files.
  • Put the zip file and screen shots (Word document that contains programming code and screen shots of program output) in the Dropbox.

i L A B S T E P S

STEP 1: Understand the UML Class Diagram
Use the following UML diagram to build the class. The first section specifies the attributes. The second section specifies the behaviors, and the first character specifies the access modifier value, where:

  • “-” means that the class member is private, and
  • “+” means that the class member is public.

Employee

- firstName : string

- lastName : string

- gender : char

- dependents : int

- annualSalary : double

+Employee()

+Employee(in first : string, in last : string, in gen : char, in dep : int, in salary : double)

+calculatePay() : double

+displayEmployee() : void

+getFirstName() : string

+setFirstName(in first : string)

+getLastName() : string

+setLastName(in last : string)

+getGender() : char

+setGender(in gen : char)

+getDependents() : int

+setDependents(in dep : int)

+getAnnualSalary() : double

+setAnnualSalary(in salary : double)

STEP 2: Code the Employee Class

  1. Create a new project called “CIS247B_WK2_Lab_LASTNAME”.
  2. Using the provided Class Diagram from Step 1, code the Employee class in the new project (i.e., “Realize the UML Class diagrams”).
  3. The default constructor should set the attributes as follows:
    • firstName = “not given”
    • lastName = “not given”
    • gender = “U” (for unknown)
    • dependents = 0
    • annualSalary = 20,000

The multi-arg constructor should initialize all of the attributes using values passed in using its parameter list. As shown in the Class diagram, each attribute should have a “getter” to retrieve the stored attribute value, and a “setter” that modifies the value. The calculatePay( ) method of the Employee class should return the value of annual salary divided by 52 (return annualSalary / 52;). The displayEmployee() method should display all the attributes of the Employee object in a well-formatted string with logical labels applied to each attribute. Don’t forget to call calculatePay from within the displayEmployee method in order to display the Employee’s weekly pay as well! Inside displayEmployee, create a NumberFormat object for currency with the following:

  1. NumberFormat nf = NumberFormat.getCurrencyInstance();
  2. Display the pay with the following:
  3. System.out.println(“Employee Pay: ” + nf.format(pay));

STEP 3: Code the Main Program
In the Main class, create code statements that perform the following operations. Be sure you follow proper commenting and programming styles (header, indentation, line spacing, etc.).

  1. Create an Employee object using the default constructor.
  2. Prompt for and then set the first name, last name, gender, dependents, and annual salary. (Remember that you have to convert gender, dependents, and annual salary from strings to the appropriate data type.)
  3. Using your code from last week, display a divider that contains the string “Employee Information”
  4. Display the Employee information.
  5. Create a second Employee object using the multi-argument constructor, setting each of the attributes with appropriate valid values.
  6. Using your code from last week, display a divider that contains the string “Employee Information”.
  7. Display the Employee information for the second Employee object.

STEP 4: Compile and Test
When done, compile and run your code. Then, debug any errors until your code is error-free.
Check your output to ensure that you have the desired output, modify your code as necessary, and rebuild.
Your output should resemble the following:

Screenshot of a program output that reads:

*************** Employee Information ***************

First Name: John

Last Name: Doe

Gender: M

Dependents: 3

Annual Salary: $46,000.00

Weekly Pay: $884.62

*************** Employee Information ***************

First Name: Sue

Last Name: Smith

Gender: F

Dependents: 3

Annual Salary: $52,000.00

Weekly Pay: $1,000.00

STEP 5: Submit Deliverables

  • Capture the Console output window and paste into a Word document.
  • Put the zip file and screen shots (Word document) in the Dropbox.

Submit your lab to the Dropbox located on the silver tab at the top of this page. For instructions on how to use the Dropbox, read theseStep-by-Step Instructionsor watch thisDropbox Tutorial.
See Syllabus “Due Dates for Assignments & Exams” for due date information.

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

iLab 3 of 7: Overloaded Methods and Static Methods / Variables

Submit your assignment to the Dropbox located on the silver tab at the top of this page.
(See Syllabus “Due Dates for Assignments & Exams” for due dates.)

i L A B O V E R V I E W
Scenario and Summary
The objective of the lab is to take the UML Class diagram and enhance last week’s Employee class by making the following changes:

  1. Create a static variable called numEmployees that holds an int and initialize it to zero. This will allow us to count all the Employee objects created in the main class.
  2. Increment numEmployees in all of the constructors
  3. Add overloaded versions of setDependents and setAnnualSalary that accept strings. This way, we will have two “set” methods for both dependents and annual salary; one that accepts a string, and one that accepts its default data type.

Deliverables
Due this week:

  • Capture the Console output window and paste it into a Word document.
  • Zip the project folder files.
  • Put the zip file and screen shots (Word document that contains programming code and screen shots of program output) in the Dropbox.

i L A B S T E P S
STEP 1:
Understand the UML Diagram

  • The following attribute has been added:

static numEmployees: int = 0

  • The following behaviors have been added:

static getNumEmployees( ) : int

setDependents(in dep : String) : void

setAnnualSalary(in sal : String) : void

STEP 2: Create the Project

You will want to use the Week 2 project as the starting point for the lab. To do this, you will want to create a new project by following these steps:

  1. Open the same workspace you created for the Week 2 project.
  2. Create a new project named “CIS247B_WK3_Lab_LASTNAME”. An empty project will then be created.
  3. Copy your main class and employee class files from Week 2 and paste them into the Week 3 project.
  4. Before you move on to the next step, build and execute the Week 3 project.
    For each week’s assignments, you will follow these steps create a new project that reuses the program from the previous week.

STEP 3: Modify the Employee

Using the UML Diagrams from Step 1, code the changes to the Employee class.

  1. Create a static numEmployees variable and initialize it to zero.
  2. Increment numEmployees by 1 in each of the constructors.
  3. Create an overloaded setDependents method and, this time, make the parameter a string.
  4. Create an overloaded setAnnualSalary method and, this time, make the parameter a string.
    Remember that you will have to convert the string in the above two “set” methods to the data type of the attribute.
  5. Make the getNumEmployees a static method. (This way, you can call it with the class name instead of an object name.)

Be sure you follow proper commenting and programming styles (indentation, line spacing, etc.).

STEP 4: Modify the Main Method

In the Main class, create code statements that perform the following operations. Be sure you follow proper commenting and programming styles (header, indentation, line spacing, etc.). Note that several of the steps below were accomplished in last week’s assignment. New steps are in bold.

  1. Create an Employee object using the default constructor.
  2. Prompt for and then set the first name, last name, and gender. Consider using your getInput method from Week 1 to obtain data from the user for this step as well as Step 3.
  3. Prompt for and then set dependents and annual salary using the new overloaded setters.
  4. Using your code from Week 1, display a divider that contains the string “Employee Information”.
  5. Display the Employee Information.
  6. Display the number of employees created using getNumEmployees. Remember to access getNumEmployees using the class name, not the Employee object.
  7. Create a second Employee object using the multi-arg constructor, setting each of the attributes with the following values: “Mary”, “Noia”, ‘F’, 5, 24000.0
  8. Using your code from Week 1, display a divider that contains the string “Employee Information”.
  9. Display the employee information for the second Employee object.
  10. Display the number of employees created using getNumEmployees. Remember to access getNumEmployees using the class name, not the Employee object.

STEP 5: Compile and Test

When done, compile and run your code. Debug any errors until your code is error-free.
Check your output to ensure that you have the desired output, modify your code as necessary, and rebuild.
Your output should resemble the following:

STEP 6: Submit Deliverables

  • Capture the output window and paste it into a Word document.
  • Put the zip file and screen shots (Word document) in the Dropbox.

Submit your lab to the Dropbox located on the silver tab at the top of this page. For instructions on how to use the Dropbox, read these Step-by-Step Instructions or watch this Dropbox Tutorial.
See Syllabus “Due Dates for Assignments & Exams” for due date information.

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

iLab 4 of 7: Composition and Class Interfaces

Submit your assignment to the Dropbox located on the silver tab at the top of this page.
(See Syllabus “Due Dates for Assignments & Exams” for due dates.)
i L A B O V E R V I E W
Scenario and Summary
The objective of the lab is to modify the Employee class to demonstrate composition and a class interface. An employee typically has benefits, so we will make the following changes:

  1. Create a Benefits class.
  2. Integrate the Benefit class into the Employee class.
  3. Create an iEmployee abstract class to guarantee that calculatePay is implemented in the

Employee class. A tutorial on interfaces can be downloaded here.
Deliverables

Due this week:

  • Capture the console output window and paste it into a Word document.
  • Zip the project folder files.
  • Put the zip file and screen shots (Word document that contains programming code and screen shots of program output) in the Dropbox.

i L A B S T E P S
STEP 1:
Understand the UML Diagram

The only change to the Employee class is that there is a new attribute:
+benefit : Benefit
Notice that there is a “+” for this attribute, meaning that it is public. Make sure to examine the multi-arg constructor’s signature!
Also, the dotted directed line between Employee and iEmployee specifies that the Employee class must implement the iEmployee abstract class, and thus provide an implementation for the calculatePay method.
STEP 2: Create the Project

You will want to use the Week 3 project as the starting point for the lab. To do this, you will want to create a new project by following these steps:

  1. Open the same workspace you created for the Week 3 project.
  2. Create a new project and name it “CIS247B_WK4_Lab_LASTNAME”.
  3. Copy all the source files from the Week 3 project into the Week 4 project.
  4. Before you move on to the next step, build and execute the Week 4 project.

STEP 3: Modify the Employee Class

  1. Using the UML Diagrams from Step 1, create the Benefit class. To get an idea of how to format displayBenefits, take a look at the output in Step 5.
  2. Add a Benefit attribute to the Employee class.
  3. Initialize the new Benefit attribute in both Employee constructors. Again, take note of the multi-arg constructors parameter list!
  4. Create the iEmployee interface.
  5. Modify the Employee class to implement the new interface so that Employee will have to implement the calculatePay method.
  6. Modify the Employee class to call displayBenefit when displaying Employee information.

STEP 4: Modify the Main Method

Notice that the Employee class now has a public benefit object inside it. This means that you can access the set methods of the Benefit object with the following code:
.benefit.
As an example, to set the lifeInsurance attribute inside an Employee object called emp, we could execute the following code:
emp.benefit.setLifeInsurance(lifeInsurance);
The steps required to modify the Main class are below. New steps are in bold.

  1. Create an Employee object using the default constructor.
  2. Prompt for and then set the first name, last name, and gender. Consider using your getInput method from Week 1 to obtain data from the user for this step as well as Step 3.
  3. Prompt for and then set the dependents and annual salary using the overloaded setters that accept Strings.
  4. Prompt for and set healthInsurance, lifeInsurance, and vacation.
  5. Using your code from Week 1, display a divider that contains the string “Employee Information”.
  6. Display the Employee Information.
  7. Display the number of employees created using getNumEmployees(). Remember to access getNumEmployees using the class name, not the Employee object.
  8. Create a Benefit object called benefit1 using the multi-arg constructor. Use any information you want for health insurance, life insurance, and vacation.
  9. Create another Employee object and use the constructor to fill it with the following:
    “Mary”, “Noia”, ‘F’, 5, 24000.0, benefit1
  10. Using your code from Week 1, display a divider that contains the string “Employee Information”.
  11. Display the employee information.
  12. Display the number of employees created using getNumEmployees(). Remember to access getNumEmployees using the class name, not the Employee object.

STEP 5: Compile and Test

When done, compile and execute your code. Debug any errors until your code is error-free.
Check your output to ensure that you have the desired output, modify your code as necessary, and rebuild.
Your output should resemble the following:

Screenshot of program that reads:

************** Employee Information **************

First Name: John

Last Name: Doe

Gender: M

Dependents: 2

Annual Salary: $73,000.00

Weekly Pay: $1,403.85

Health Insurance: Partial

Life Insurance: 500.0

Vacation: 10

Total employees: 1

*************** Employee Information ***************

First Name: Mary

Last Name: Noia

Gender: F

Dependents: 5

Annual Salary: $24,000.00

Weekly Pay: $461.54

Health Insurance: Full

Life Insurance: 100.0

Vacation: 5

Total employees: 2

STEP 6: Submit Deliverables

  • Capture the Console output window and paste it into a Word document.
  • Put the zip file and screen shots (Word document) in the Dropbox.

Submit your lab to the Dropbox located on the silver tab at the top of this page. For instructions on how to use the Dropbox, read these Step-by-Step Instructions or watch this Dropbox Tutorial.
See Syllabus “Due Dates for Assignments & Exams” for due date information.

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Week 5: Composition, Inheritance, and Polymorphism - iLab

iLab 5 of 7: Inheritance

Submit your assignment to the Dropbox located on the silver tab at the top of this page.
(See Syllabus “Due Dates for Assignments & Exams” for due dates.)
i L A B O V E R V I E W
Scenario and Summary
The objective of the lab is to take the UML Class diagram and enhance last week’s Employee class by making the following changes:

  1. Create a class called Salaried that is derived from Employee.
  2. Create a class called Hourly that is also derived from Employee.
  3. Since all classes/objects inherit from java.lang.object class, change the “displayClass” information method to override the java.lang.object “toString” method.
  4. Override necessary method(s) in each of the new subclasses as applicable.

Deliverables
Due this week:

  • Capture the console output window and paste into a Word document.
  • Zip the project folder file.
  • Put the zip file and screenshots (Word document) in the Dropbox.

i L A B S T E P S

STEP 1: Understand the UML Diagram

Notice the change in UML diagram. It is common practice to leave out the accessors and mutators (getters and setters) from UML class diagrams, since there can be so many of them. Unless otherwise specified, it is assumed that there is an accessor (getter) and a mutator (setter) for every class attribute.

Employee

#firstName : string

#lastName : string

#gender : char

#dependents : int

#annualSalary : double

#benefit : Benefit

-static numEmployees : int = 0

+Employee()

+Employee(in fname : string, in lname : string, in gen : char, in dep : int, in benefits : Benefit)

+static getNumEmployees() : int

+CalculatePay() : double

+displayEmployee() : void

Benefit

-healthinsurance : string

-lifeinsurance : double

-vacation : int

+Benefit()

+Benefit(in hins : string, in lins : double, in vac : int)

+displayBenefits() : void

Salaried

-MIN_MANAGEMENT_LEVEL : int = 0

-MAX_MANAGEMENT_LEVEL : int = 3

-BONUS_PERCENT : double = 10

-managementLevel : int

+Salaried()

+Salaried(in fname : string, in lname : string, in gen : char, in dep : int, in sal : double, in ben : Benefit, in manLevel : int)

+Salaried(in sal : double, in manLevel : int)

+CalculatePay() : double

+displayEmployee() : void

Hourly

-MIN_WAGE : double = 10

-MAX_WAGE : double = 75

-MIN_HOURS : double = 0

-MAX_HOURS: double = 50

-wage : double

-hours : double

-category : string

+Hourly()

+Hourly(in wage : double, in hours : double, in category : string)

+Hourly(in fname : string, in lname : string, in gen : char, in dep : int, in wage : double, in hours : double, in ben : Benefit, in category : string)

+CalculatePay() : double

+displayEmployee() : void
STEP 2: Create the Project

Create a new project and name it CIS247B_WK5_Lab_LASTNAME. Copy all the source files from the Week 4 project into the Week 5 project.
Before you move on to the next step, build and execute the Week 5 project.
STEP 3: Modify the Benefits Class

All classes that are contained in Java’s API as well as any external classes that you or I may create are derived from the java.lang.object class. The Object class contains several methods which are inherited by all other Java classes. One of these methods is called toString. The toString method can be overridden by any class and its purpose is to display an object’s current state. This type of functionality should sound familiar to you. After all, your displayBenefits method was designed to print the current state of a Benefit object! In this week’s lab, we are going to move the logic contained in displayBenefits to the toString method. Take a look at Java’s description of the toString method contained in the Object class and pay particular attention to its return type before moving on.

  1. Change the displayBenefits method to override the java.lang.object toString method by simply changing its name from displayBenefits to toString.
  2. Ensure the toString method returns a String and does not explicitly display the state information to the console. Remember, toString does not display information but instead it simply returns a string.

STEP 4: Modify the Employee Class

Java provides three explicit access modifiers for attributes and methods. So far, we have dealt with two of them: public and private. This week, we will use a new access modifier: protected. Java states that “The protected modifier specifies that the member can only be accessed within its own package (as with package-private) and, in addition, by a subclass of its class in another package.” For additional information on the use of protected as an access modifier, review the Controlling Access to Members of a Class tutorial.

  1. Using the updated Employee class diagram, modify attributes to be protected as necessary.
  2. Change the name of the displayEmployee method to “toString” and modify the new toString method to return an Employee’s information as a String. This overrides the java.lang.object toString method.
  3. Delete the iEmployee interface class, and remove the reference from the Employee class.

STEP 5: Create the Salaried Class

In this step, it is necessary to implement constant attributes. As the name implies, constants contain values that do not change. In Java, an attribute is made into a constant by adding the keywords “static final” in the declaration. For additional information on the creation and use of constants, review the Understanding Instance and Class Members tutorial.
One other very important concept to review for this step in the lab is the use of the super method. Super is used to access parent-defined attributes and methods within a subclass. A common practice is to use the code super() or super(arg-list) to invoke the constructor in a parent class. For additional information on the use of super in your application and specifically this week’s constructors, review the Using the Keyword super tutorial.

  1. Using the UML Diagrams from Step 1, create the Salaried classes, ensuring to specify that the Salary class inherits from the Employee class.
  2. For each of the constructors listed in the Salaried class, ensure to invoke the appropriate superclass constructor and pass the correct arguments to the superclass constructor. This will initialize the protected attributes and update the numEmployees counter. Don’t forget to initialize the attributes for Salaried as well!
  3. The valid management levels are 0, 1, 2, and 3, and the min and max management level attributes should be implemented as constants. Make sure to enforce this set of valid values in the management level setter.
  4. Override the calculatePay method to add a 10 percent bonus to the annual salary for each of the management levels (i.e., bonus percentage = managementLevel * BONUS_PERCENT). The bonus percentage should be implemented as a constant. Also remember, the value returned from calculatePay should be equal to an employee’s weekly pay.
  5. Override the toString method to add the management level to the employee information. Don’t forget to call Employee’s toString method to capture the state of the inherited Employee attributes!

STEP 6: Create the Hourly Class

  1. Using the UML Diagrams from Step 1, create the Hourly class, ensuring to specify that the Hourly class inherits from the Employee class.
  2. For each of the constructors listed in the Hourly class, ensure to invoke the appropriate base class constructor and pass the correct arguments to the base class constructor. This will initialize the protected attributes and update the numEmployees counter.
  3. The valid category types are “temporary”, “part time”, and “full time”. (Hint: The use of String.equalsIgnoreCase may be useful when setting the value of category. Search through Java’s API for more details on the use of equalsIgnoreCase.)
  4. The value for hours must be greater than or equal to 0 and less than or equal to 50. The limits should be implemented as constants.
  5. The provided wage must be between 10 and 75 inclusive, and the limits should be implemented as constants.
  6. Make sure to update the value of annualSalary appropriately every time the value of wage or hours changes. Remember, an Hourly employee’s annual salary is calculated using the following formula: wage * hours * 52. Therefore, any change to wage or hours will affect the employee’s annual salary!
  7. Override the toString method to add the category to the hourly employee information.

STEP 7: Construct the Main Method

  1. Using previous weeks’ assignments as an example, create at least one Employee, Hourly, and Salaried employee.
  2. For each object created, write statements to exercise each of the public methods listed in the class diagram.
  3. For each object created, invoke the object’s toString method to display the employee’s information.
  4. For each object created, display the number of employees created.

STEP 8: Compile and Test

When done, compile and execute your code, and debug any errors until your code is error-free.
Check your output to ensure that you have the desired output, modify your code as necessary, and rebuild.
Your output should resemble the following. Make sure to fully exercise all of your new and overridden subclass methods. This could result in output that is lengthier than the example below.

Screenshot of program that reads:

************** Employee Information **************

First Name: George
Last Name: Anderson
Gender: M
Dependents: 5
Annual Salary: $42,000.00
Weekly Pay: $807.69
Health Insurance: Full
Life Insurance: 2000.0
Vacation: 10
Total employees: 1

*************** Employee Information ***************

First Name: Mary
Last Name: Noia
Gender: F
Dependents: 5
Annual Salary: $24,000.00
Weekly Pay: $507.69
Health Insurance: Full
Life Insurance: 1000.0
Vacation: 5
Management Level: 1
Total employees: 2

*************** Employee Information ***************

First Name: Frank
Last Name: Jones
Gender: M Dependents: 3
Annual Salary: $23,400.00
Weekly Pay: $450.00
Health Insurance: None
Life Insurance: 500.0
Vacation: 3
Category: Part-time
Total employees: 3

*************** Revised Employee Information ***************

First Name: Frank
Last Name: Jones
Gender: M
Dependents: 3
Annual Salary: $33,280.00
Weekly Pay: $640.00
Health Insurance: None
Life Insurance: 500.0
Vacation: 3
Category: Part-time
Total employees: 3

STEP 9: Submit Deliverables

  • Capture the console output window and paste it into a Word document.
  • Put the zip file and screenshots (Word document) in the Dropbox.

Submit your lab to the Dropbox located on the silver tab at the top of this page. For instructions on how to use the Dropbox, read these Step-by-Step Instructions or watch this Dropbox Tutorial.
See Syllabus “Due Dates for Assignments & Exams” for due date information.

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Week 6: Interfaces and Abstract Classes – iLab

iLab 6 of 7: Abstract Class and Polymorphism

Submit your assignment to the Dropbox located on the silver tab at the top of this page.
(See Syllabus “Due Dates for Assignments & Exams” for due dates.)
i L A B O V E R V I E W
Scenario and Summary
We have two separate goals this week:

  1. We are going to create an abstract Employee class and an abstract calculatePay method. The abstract Employee class will prevent a programmer from creating an object based on Employee. Only objects based on Salaried and Hourly will be allowed. The abstract calculatePay method in Employee will force the child classes to implement calculatePay.
  2. We are going to implement Polymorphism and dynamic binding by creating generalized methods that accept generalized Employee objects to collect input and display information. However, in the main method we will pass derived objects of the Employee class into the methods.

Deliverables
Due this week:

  • Capture the console output window and paste it into a Word document.
  • Zip the project files.
  • Put the zip file and screenshots (Word document) in the Dropbox.

i L A B S T E P S

STEP 1: Understand the UML Diagram

Notice in the updated UML diagram that the Employee class is designated as abstract by having the class name Employee italicized. Also, the calculatePay method is italicized, which means that it is an abstract method and needs to be implemented in the derived classes.

Employee

#firstName : string

#lastName : string

#gender : char

#dependents : int

#annualSalary : double

#benefit : Benefit

-static numEmployees : int = 0

+Employee()

+Employee(in fname : string, in lname : string, in gen : char, in dep : int, in benefits : Benefit)

+static getNumEmployees() : int

+CalculatePay() : double

+displayEmployee() : void

Benefit

-healthinsurance : string

-lifeinsurance : double

-vacation : int

+Benefit()

+Benefit(in hins : string, in lins : double, in vac : int)

+displayBenefits() : void

Salaried

-MIN_MANAGEMENT_LEVEL : int = 0

-MAX_MANAGEMENT_LEVEL : int = 3

-BONUS_PERCENT : double = 10

-managementLevel : int

+Salaried()

+Salaried(in fname : string, in lname : string, in gen : char, in dep : int, in sal : double, in ben : Benefit, in manLevel : int)

+Salaried(in sal : double, in manLevel : int)

+CalculatePay() : double

+displayEmployee() : void

Hourly

-MIN_WAGE : double = 10

-MAX_WAGE : double = 75

-MIN_HOURS : double = 0

-MAX_HOURS: double = 50

-wage : double

-hours : double

-category : string

+Hourly()

+Hourly(in wage : double, in hours : double, in category : string)

+Hourly(in fname : string, in lname : string, in gen : char, in dep : int, in wage : double, in hours : double, in ben : Benefit, in category : string)

+CalculatePay() : double

+displayEmployee() : void
STEP 2: Create the Project

Create a new project and name it CIS247B_WK6_Lab_LASTNAME. Copy all the source files from the Week 5 project into the Week 6 project.
Before you move on to the next step, build and execute the Week 6 project.
STEP 3: Modify the Employee Class

  1. Make the Employee class abstract.
  2. Define calculatePay as an abstract method.

STEP 4: Modify the Hourly Class

Implement the calculatePay method. Since calculatePay is not declared as an abstract method in Employee, all subclasses of Employee must provide an implementation for calculatePay. Unlike the Salaried class, the Hourly class does not currently have an implementation for calculatePay and this will cause an error!
STEP 5: Modify the Main Class – Create Generalized Input Methods

In your Main class, create a method called collectEmployeeInformation that accepts as an argument an Employee object and prompts the user for all the employee attributes, retrieves the attributes, makes any necessary conversions, and then sets the attribute value in the object. Remember you may pass both Salaried and Hourly objects into this method. Therefore it will be necessary to determine which type of object you are deal with, at runtime, using the getClass method. The following is an example of how you might use the getClass method:

if (employee.getClass() == Salaried.class){ // Put code here that is specific to Salaried objects } else { // Put code here that is specific to Hourly objects }
Once you have determined the type of object you are dealing with, you will also need to cast that object to the correct type in order to access its class-specific methods. In order to cast a general Employee object to a Salaried object and access one of its class-specific methods, you would do the following:
((Salaried)employee).methodInSalariedClass;
We are also going to implement error handing this week using a try/catch block. Specifically, you should wrap the code used to acquire and set the life insurance amount and vacation days in try-catch blocks as shown below. The “try” portion of the code looks for an error. If an error occurs parsing the integer, it jumps down to the “catch” portion of the code and displays the error message. Because badInput is still true, it loops back to the “do” and starts over. Once the integer is parsed correctly, badInput is set to false so it exits the loop and correctly sets the value for vacation.

boolean badInput = true;

String strVacation = “”; //Must be initialized vacation = 0; //Must be initialized

do {

      try {

              strVacation = JOptionPane.showInputDialog(“Vacation: “);

              vacation = Integer.parseInt(strVacation);//Possible Error

              badInput = false;

            } catch (Exception ex) {

               JOptionPane.showMessageDialog(null,strVacation + ” is not an integer”,”Error”,JOptionPane.PLAIN_MESSAGE);

            }

     } while(badInput);

STEP 6: Modify the Main Class – Create a Generalized Output Method

Create a method called displayEmployeeInformation that accepts an Employee object, provides an output header string, and then displays Employee information.
STEP 7: Modify the Main Class – Create a Display Number Employee Method

Create a method called displayNumberOfEmployees to display the number of employee objects.
STEP 8: Modify the Main Method

  1. Create an array of employee objects with: Employee employeeList[] = new Employee[2];
  2. For the first employeeList index, create a Salaried employee.
  3. Call the collectEmployeeInformation method, passing in the Salaried object.
  4. Use the displayEmployeeInformation method to display the object’s state.
  5. Use the displayNumberEmployees method to display the total number of Employees created. Remember, this includes both Salaried and Hourly employees.
  6. For the second employeeList index, create an Hourly employee.
  7. Repeat Steps 3-5 for the Hourly object.
  8. As an educational exercise, you can try to create an Employee object to verify that an error will occur.

STEP 9: Compile and Test

When done, compile and execute your code, and debug any errors until your code is error-free.
Check your output to ensure that you have the desired output, modify your code as necessary, and rebuild.
All of the output values should match last week’s output.
STEP 10: Submit Deliverables

Submit your lab to the Dropbox located on the silver tab at the top of this page. For instructions on how to use the Dropbox, read these Step-by-Step Instructions or watch this Dropbox Tutorial.
See Syllabus “Due Dates for Assignments & Exams” for due date information.

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

iLab 7 of 7: Putting It All Together

Submit your assignment to the Dropbox located on the silver tab at the top of this page.
(See Syllabus “Due Dates for Assignments & Exams” for due dates.)

i L A B O V E R V I E W
Scenario and Summary
This week, you will be implementing inheritance by creating a generic Racer superclass along with two subclasses called StreetTuner and HotRod. You will make the Racer class abstract and include the abstract method IsDead in the Racer class.
Deliverables
Due this week:

  • Capture the console output window and paste it into a Word document.
  • Zip the project folder.
  • Put the zip file and screenshots (Word document) in the Dropbox.

i L A B S T E P S
STEP 1:
Understand the UML Diagram

Engine:

-cylinders: int

-horsepower:int

+Engine()

+Engine(in cylinders: int , in horsePower :int)

+toString(): string

Racer:

-name: string

-speed: int

-eng: Engine

+Racer()

+Racer(in name: string, in speed:int, in engine: Engine)

+isDead():bool +toString():string

HotRod (point to Racer):

-blower:bool

+HotRod()

+HotRod(in name: string, in speed: int, in engine: Engine, in blower: bool)

+isDead():bool

+toString():string

StreetTuner (point to Racer):

-nitrous: bool

+StreetTuner()

+StreetTuner(in name: string, in speed:int, in engine: Engine, in nitrous:bool)

+isDead():bool

+toString(): string
STEP 2: Build the Inheritance Hierarchy

Create a project called “CIS247B_WK7_Lab_LASTNAME”
Build the class structure shown in the UML diagram. Remember to include getters and setters for each class attribute.
STEP 3: Implement Logic for HotRod Class

  1. Provide suitable logic for the toString method. As always, the toString method should reveal the state of an object.
  2. For the isDead method in HotRod, use the logic below to implement the inherited base class abstract method called isDead.

Hint: To generate a random number, use the following code, which returns a random number from 0 to 1:
Random rnd = new Random();
rnd.NextDouble();

Pseudocode for the isDead method of HotRod:

 Random rnd = new Random();

boolean dead if (speed > 50 && rnd.NextDouble() > 0.6)

if (engineHorsePower < 300 && blower=true)

dead = false

else

dead = true

end if else if (speed > 100 && rnd.NextDouble() > 0.4)

if (engineHorsePower >= 300 && blower = true)

dead = true

else

dead = false

end if

else

dead = false

end if
STEP 4: Implement Logic for StreetTuner Class

  1. Provide suitable logic for the toString method. As always, the toString method should reveal the state of an object.
  2. For the isDead() method in StreetTuner, use the logic below to implement the inherited base class abstract method called isDead.

Pseudocode for the isDead method of StreetTuner

Random rnd = new Random();

boolean dead if (speed > 50 && rnd.NextDouble() > 0.6)

if (engineHorsePower < 300 && nitrous=true)

dead = false

else

dead = true

end if

else if (speed > 100 && rnd.NextDouble() > 0.4)

if (engineHorsePower >= 300 && nitrous = true)

dead = true

else

dead = false

end if

else

dead = false

end if
STEP 5: Construct the Main Program

Hint: When completing the Main Class for your lab, feel free to reuse old methods from previous labs!

  1. Create an array of Racer objects that will hold three Racer objects.
  2. Write a method, called collectRacerInformation that accepts as an argument a Racer object, and then prompts the user to provide the following information for each racer.
    1. Racer name
    2. Racer Speed
    3. Number of cylinders in the racer’s engine
    4. Horsepower of the racer’s engine
  3. Add logic to collectRacerInformation to determine if the Racer object passed in is a HotRod or a StreetTuner. If it is a HotRod, prompt the user to indicate the existence of a blower. If the object is a StreetTuner, prompt the user to indicate the existence of nitrous. Set these values appropriately.
  4. Write a method called displayRacerInformation that accepts as an argument a Racer object, and then displays all the information for the specific racer type.
  5. Create any combination of Racer objects (make sure you create at least one StreetTuner and one HotRod) and invoke collectRacerInformation, passing in each of the Racer objects. Store each object in the array. For StreetTuner objects, be sure to set the nitrous flag (either true or false), and for the HotRod objects set the blower flag (either true or false).
  6. Iterate through the racer array and, for each Racer object, display all the object’s attribute information (call the displayRacerInformation method for each object). Don’t forget to indicate whether or not the Racer is dead!

STEP 6: Compile and Test

When done, compile and execute your code, and debug any errors until your code is error-free.
Check your output to ensure that you have the desired output, modify your code as necessary, and rebuild.
Your code may resemble the following:

************Racer Information*************

Name: HotRod Racer

Speed: 85

**Engine Information**

Cylinders: 8

Horse Power: 100

Blower: true

Is the Racer dead? No

**************Racer Information****************

Name: StreetTuner Racer #1

Speed: 95

**Engine Information**

Cylinders: 10

Horse Power: 135

Nitrous: false

Is the Racer dead? Yes

*****************Racer Information***************

name: StreetTuner Racer #2

Speed: 103

**Engine Information**

Cylinders 12

Horse Power: 150

Nitrous: true

Is the Racer dead? No
STEP 7: Submit Deliverables

Submit your lab to the Dropbox located on the silver tab at the top of this page. For instructions on how to use the Dropbox, read these Step-by-Step Instructions or watch this Dropbox Tutorial.
See Syllabus “Due Dates for Assignments & Exams” for due date information.

Complete solution for CIS247 course in Java

It is 100% correct solution

How to using solution?

Using any Java IDE (ex Eclipse or Netbean), copy all source codes to src folder, then open and run main class

If you have more questions, please contact me via email support@extutorials.com, i will help you any time

Thank you

Attached Files

Move over [ preview ] file name to preview content in it!

  • CIS247B-Java.zip [2748.2KB]
    • CIS247B-Week1
    • CIS247B-Week2
    • CIS247B-Week3
    • CIS247B-Week4
      • Document.docx [341.5KB]
      • Eclipse Project
        • CIS247B_WK4_Lab_LASTNAME
          • .classpath
            • .project
              • bin
              • src
                • Benefit.java [1KB] [ preview ]
                • Employee.java [4.1KB] [ preview ]
                • iEmployee.java [61Bytes] [ preview ]
          • ScreenShot-CIS247B-Week4.jpg [132.8KB]
          • source code
            • Benefit.java [1KB] [ preview ]
            • Employee.java [4.1KB] [ preview ]
            • iEmployee.java [61Bytes] [ preview ]
        • CIS247B-Week5
          • Document.docx [324.9KB]
          • Eclipse Project
            • CIS247B_WK5_Lab_LASTNAME
              • .classpath
                • .project
                  • bin
                  • src
                    • Benefit.java [1.1KB] [ preview ]
                    • Employee.java [2.7KB] [ preview ]
                    • Hourly.java [3.3KB] [ preview ]
                    • Salaried.java [1.9KB] [ preview ]
              • ScreenShot-CIS247B-Week5.jpg [121.6KB]
              • source code
                • Benefit.java [1.1KB] [ preview ]
                • Employee.java [2.7KB] [ preview ]
                • Hourly.java [3.3KB] [ preview ]
                • Salaried.java [1.9KB] [ preview ]
            • CIS247B-Week6
              • Document.docx [158.7KB]
              • Eclipse Project
                • CIS247B_WK6_Lab_LASTNAME
                  • .classpath
                    • .project
                      • bin
                      • src
                        • Benefit.java [1.1KB] [ preview ]
                        • Employee.java [5.3KB] [ preview ]
                        • Hourly.java [3.7KB] [ preview ]
                        • Salaried.java [2KB] [ preview ]
                  • ScreenShot1-CIS247B-Week6.jpg [13.4KB]
                  • ScreenShot2-CIS247B-Week6.jpg [10.9KB]
                  • ScreenShot3-CIS247B-Week6.jpg [28.8KB]
                  • source code
                    • Benefit.java [1.1KB] [ preview ]
                    • Employee.java [5.3KB] [ preview ]
                    • Hourly.java [3.7KB] [ preview ]
                    • Salaried.java [2KB] [ preview ]
                • CIS247B-Week7
                  • Document.docx [488.9KB]
                  • Eclipse Project
                    • CIS247B_WK7_Lab_LASTNAME
                      • .classpath
                        • .project
                          • bin
                          • src
                            • Engine.java [0.6KB] [ preview ]
                            • HotRod.java [1KB] [ preview ]
                            • Main.java [1.7KB] [ preview ]
                            • Racer.java [0.8KB] [ preview ]
                            • StreetTuner.java [1.1KB] [ preview ]
                      • ScreenShot-CIS247B-Week7.jpg [108.8KB]
                      • source code
                        • Engine.java [0.6KB] [ preview ]
                        • HotRod.java [1KB] [ preview ]
                        • Main.java [1.7KB] [ preview ]
                        • Racer.java [0.8KB] [ preview ]
                        • StreetTuner.java [1.1KB] [ preview ]

                  Write a review

                  Your Name:


                  Your Review: Note: HTML is not translated!

                  Rating: Bad           Good

                  Enter the code in the box below:



                  PURCHASE SAVE
                  2 Tutorials 10%
                  3 Tutorials 13%
                  4 Tutorials 16%
                  5 Tutorials 19%
                  6 Tutorials 22%
                  7 Tutorials 25%
                  8 Tutorials 28%
                  9 Tutorials 31%
                  10 Tutorials 34%
                  add url more

                  9MZQASHWN73B