Print iLab 5 of 7: Inheritance Remember This! Connect to the iLab here. Note! 

Print

 

iLab 5 of 7: Inheritance

Remember This!

Connect to the iLab here.

Note!

Submit your assignment to the Dropbox located on the silver tab at the top of this page.

(See the Syllabus section “Due Dates for Assignments & Exams” for due dates.)

iLAB OVERVIEW

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 derived class called Salaried that is derived from Employee.

2.Create a derived class called Hourly that is derived from Employee.

3.Create generalized input methods that accept any type of Employee or derived Employee object

4.Create generalized output methods that accept any type of Employee or derived Employee object

5.Override the base class CalculatePay method

6.Override one of the base class CalculateWeeklyPay methods

Deliverables

Due this week:

•Capture the Console output window and paste into a Word Document.

•Zip the project folder.

•Put the zip file and screenshots (word document) in the drop box.

iLAB STEPS

STEP 1: Understand the UML Diagram

Back to Top

 

Analyze and understand the object UML diagram, which models the structure of the program.

•There are two new Employee derived classes (1) Salaried and (2) Hourly that are derived from the Employee class.

•The Employee class contains a new attribute employeeType and a new constructor that accepts as an argument the assigned employee type.

•Both the Salaried and the Hourly classes override only the CalculateWeeklyPay method of the Employee class (note, this is the method without any parameters.)

•The Salaried class has one attribute “managementLevel” that has possible values from MIN_MANAGEMENT_LEVEL to MAX_MANAGEMENT_LEVEL and a BONUS_PERCENT.

•The Salaried class has a default constructor and parameterized constructor that accepts all the general employee information plus the management level.

•The Hourly has a wage attribute, which respresents the hourly wage that ranges from MIN_WAGE to MAX_WAGE, a hours attributes, which represents the number of hours worked in a week that ranges from MIN_HOURS to MAX_Hours, and a category attributes that accepts string values.

•The Hourly class has a default constructor and parameterized constructor that accepts all the general employee information plus the hours and wage value.

•The Presentation Tier contains two new classes (1) The EmployeeInput class and the EmployeeOutput class

•The EmployeeInput class contains three static methods (1) CollectEmployeeInformation, which accepts any type of Employee object as a argument; (2) CollectHourlyInformation, which accepts only Hourly objects as an argument, and (3) CollectSalariedInformation, which accepts only Salaried objects as an argument.

•The EmployeeOutput class contains two methods (1) DisplayEmployeeInformation, which accepts any Employee type as an argument and (2) DisplayNumberObjects method.

•All the access specifers for the Employee attributes are changed to protected and are depicted with the “#” symbol.

 

Image Description

STEP 2: Create the Project

Back to Top

 

You will want to use the Week 4 project as the starting point for the lab. Use the directions from the previous weeks labs to create the project and the folders.

1.Create a new project named “CIS247_WK4_Lab_LASTNAME”. An empty project will then be created.

2.Delete the default Program.cs file that is created.

3.Add the Logic Tier, Presentation Tier, and Utilities folders to your proejct

4.Add the Week 4 project files to the appropraties folders.

5.Update the program information in the ApplicationUtilities.DisplayApplicationInformation method to reflect your name, current lab, and program description

Note: as an alternative you can open up the Week 4 project and make modifications to the existing project. Remember, there is a copy of your project in the zip file you submitted for grading.

Before attempting this week’s steps ensure that the Week 4 project is error free.

STEP 3: Modify the Employee Class

Back to Top

1.Change the access specifier for all the private attributes to protected.

2.Add the new attribute employeeType, along with a “read only” property (that is only a “get” method) to access the employee type value.

3.Add a new constructor that only accepts the type attribute, which is then used to set the employeeType value. Also, this constructor should initialize all the default values. You can call the default constructor using the syntax: public Employee(string employeeType) : this() { }

4.Modify the parameterized constructor that accepts the employee information to accept the employee type, and then set the employeeType with this value.

5.Modify the ToString Method to include the employee type.

STEP 4: Create the Salaried Class

Back to Top

1.Using the UML Diagrams, create the Salaried class, 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 super class constructor and pass the correct arguments to the super class constructor.

3.Override the CalculateWeeklyPay method to add a 10 percent bonus to the annualSalary depending on the management level. The bonus percent is a fixed 10 percent, and should be implemented as a constant. However, depending on the management level the actual bonus percentage fluctuates (i.e., actualBonusPercentage = managementLevel * BONUS_PERCENT).

4.Override the ToString method to add the management level to the employee information.

STEP 5: Create the Hourly Class

Back to Top

1.Using the UML Diagrams, create the Hourly classes, 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 super class constructor and pass the correct arguments to the super class constructor. Notice, that the Hourly employee DOES NOT have an annual salary, which we will then have to calculate (see below).

3.Create a Category property (get/set) and the valid category types are “temporary”, “part time”, “full time”.

4.Create a Hours property (get/set) for the hours attributes and validate the input using the constants shown in the UML diagram, but since an Hourly employee does not have a formal annual salary we will need to calculate this each time the hour (and wage) properties are set. Add the following code after the validation code in the hours property: base.AnnualSalary = CalculateWeeklyPay() * 48; (assumes working 48 weeks a year).

5.Create an Wage property (get/set) for the wage attributes and validate the input using the constants shown in the UML diagram. Add the following code after the validation code in the wage property: base.AnnualSalary = CalculateWeeklyPay() * 48; (assumes working 48 weeks a year)

6.Override the CalculateWeeklyPay method by multiplying the wages by the number of hours.

7.Update the ToString method to add the category, hours, and wages to the hourly employee information.

STEP 6: Create the EmployeeInput Class

Back to Top

1.Create a new class in the Presentation Tier folder called “EmployeeInput”

2.Create a static void method called CollectEmployeeInformation that has a single Employee parameter. The declaration should look something like the following:

public static void CollectEmployeeInformation(Employee theEmployee)

3.Write code statements similiar to what you created in the Week 4 project to collect the generic employee information from the user, except instead of using specific employee objects use the “theEmployee” parameters. For example:

In Week 4, you had something like:

employee1.FirstName = InputUtilities.GetStringInputValue(“First name”);

In the CollectionEmployeeInformation method this can be translated to the following;

theEmployee.FirstName = InputUtilities.GetStringInputValue(“First name”);

4.Write statements to collect all the generic employee information, including the Benefits information, as you did in the Week 4 project. However, since not all derived types have a AnnualSalary value, DO NOT collect the annual salary data.

5.Create a new static void method called CollectEmployeeInformation that accepts an Hourly employee object. Using the InputUtilities methods write statements to collect the wage and hours from the user.

6.Create a new static void method called CollectSalariedInformation that accepts a Salaried employee object. Using the InputUtilties methods write statements to collect the management level and the annual salary.

STEP 7: Create the EmployeeOutputClass

Back to Top

1.Create a new class in the Presentation Tier folder called “EmployeeOuput”

2.Create a static void method called DisplayEmployeeInformation that has a single Employee parameter. The declaration should look something like the following:

public static void DisplayEmployeeInformation(Employee theEmployee)

3.In the DisplayEmployeeInformation method write an output statement that displays theEmployee object to string method to the console.

4.Create static method called DisplayNumberObject that displays the number of employees created.

5.Invoke these methods from the main program to display the employee information and number of objects created.

[Hint: move the the statements from the main program into these methods.]

STEP 8: Create the Main Program

Back to Top

1.Create an array of type Employee that will hold three employee objects. Create three new objects, one Employee, one Hourly and one Salaried in positions 0, 1 and 2 of the array respectively. Make sure to use the constructors the accept the employee type and provide appropriate values for the employee type (e.g. “Generic”, “Hourly”, “Salaried”).

2.Using a FOR loop iterate through the array and collect all the generic employee information, using the EmployeeInput.CollectEmployeeInformation method.

3.If the current item in the array is an Hourly object, then use the EmployeeInput.CollectHourlyInformation method to collect the hourly information.

4.If the current item in the array is a Salaried object, then use the EmployeeInput.CollectSalariedInformation method to collect the salaried information.

Use the following if statement to determine the specific type of object:

if (employeeList[i] is Hourly)

EmployeeInput.CollectHourlyInformation((Hourly)employeeList[i]);

else if (employeeList[i] is Salaried)

EmployeeInput.CollectSalariedInformation((Salaried)employeeList[i]);

5.After the information has been collected display the employee information using the EmployeeOutput.DisplayEmployeeInformation method.

6.Before terminating the program display the number of employee objects that have been created.

STEP 9: Compile and Test

Back to Top

 

When done, compile and run your program.

Then debug any errors until your code is error-free.

Check your output to ensure that you have the desired output and modify your code as necessary and rebuild.

The output of your program should resemble the following:

 

Image Description

STEP 10: Submit Deliverables

Back to Top

•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 these step-by-step instructions or watch this Dropbox Tutorial.

See the Syllabus section “Due Dates for Assignments & Exams” for due date information.

Back to Top

 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"

Print iLab 6 of 7: Abstract Classes Remember This! Connect to the iLab here. Note! 

Print

 

iLab 6 of 7: Abstract Classes

Remember This!

Connect to the iLab here.

Note!

Submit your assignment to the Dropbox located on the silver tab at the top of this page.

(See the Syllabus section “Due Dates for Assignments & Exams” for due dates.)

iLAB OVERVIEW

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.Convert the Employee class to an abstract class

2.Add an abstract method called CalculateNetPay to the Employee class

3.In both the Salaried and Hourly classes implement the CalculateNetPay method

Deliverables

Due this week:

•Capture the Console output window and paste into a Word Document.

•Zip the project folder.

•Put the zip file and screenshots (word document) in the drop box.

iLAB STEPS

STEP 1: Understand the UML Diagram

Back to Top

 

Analyze and understand the object UML diagram, which models the structure of the program.

•The Employee class has been specifed as abstract, which is denoted by the name of the class being italized Employee

•The Employee class as a new method CalculateNetPay which is an abstract method, denoted by the italized name of the method. Since this method is an abstract method the CalculateNetPay method WILL NOT have an implementation in the Employee class.

•The Salaried and Hourly classes both have a new method CalculateNetPay that is inherited from the abstract Employee class and the Salaried and Hourly class both MUST implement the CalculateNetPay method.

 

Image Description

STEP 2: Create the Project

Back to Top

 

You will want to use the Week 5 project as the starting point for the lab. Use the directions from the previous weeks labs to create the project and the folders.

1.Create a new project named “CIS247_WK4_Lab_LASTNAME”. An empty project will then be created.

2.Delete the default Program.cs file that is created.

3.Add the Logic Tier, Presentation Tier, and Utilities folders to your proejct

4.Add the Week 5 project files to the appropraties folders.

5.Update the program information in the ApplicationUtilities.DisplayApplicationInformation method to reflect your name, current lab, and program description.

Note: as an alternative you can open up the Week 5 project and make modifications to the existing project. Remember, there is a copy of your project in the zip file you submitted for grading.

Before attempting this week’s steps ensure that the Week 5 project is error free.

STEP 3: Modify the Employee Class

Back to Top

1.Modify the class declaration of the Employee class to specify that the Employee class is an abstract class

2.Declare an abstract method called CalculateNetPay that returns a double value.

3.Modify the ToString Method to include the weekly net pay in currency format.

STEP 4: Modify the Salaried Class

Back to Top

1.Add a double constant called TAX_RATE and set the value to .73

2.Implement the CalculateNetPay method by multiplying the weekly pay by the tax rate.

STEP 5: Modify the Hourly Class

Back to Top

1.Add a double constant called TAX_RATE and set the value to .82

2.Implement the CalculateNetPay method by multiplying the weekly pay by the tax rate.

STEP 6: Create the Main Program

Back to Top

1.Change the employeeList array to only hold two objects

2.Create one Hourly employee object and store it in the array.

3.Create one Salaried employee object and store it in the array.

4.As you did in the Week 5 lab, prompt for and collect the information for each of the objects.

Note: iterating through the array should not require any changes from the previous iteration of the project–but make sure that the loop stays within the bounds of the array.

STEP 7: Compile and Test

Back to Top

 

When done, compile and run your program.

Then debug any errors until your code is error-free.

Check your output to ensure that you have the desired output and modify your code as necessary and rebuild.

The output of your program should resemble the following:

 

Image Description

STEP 8: Submit Deliverables

Back to Top

•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 these step-by-step instructions or watch this Dropbox Tutorial.

See the Syllabus section “Due Dates for Assignments & Exams” for due date information.

Back to Top

PrintiLab 6 of 7: Abstract ClassesRemember This!Connect to the iLab here.Note!Submit your assignment to the Dropbox located on the silver tab at the top of this page.(See the Syllabus sec±on “Due Dates for Assignments & Exams” for due dates.)iLAB OVERVIEW
Background image of page 1
 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"

Name: Samuel GastelWeek 7 iLab—Sales TaxTCO 3: Given a simple problem, design and desk-check a solution algorithm requiring a modulardesign that is expressed in terms of pseudocode or program notes

Hi! I need some help with this assignment. I’ve attached a blank document and need for it to be filled out. The

only thing I’ve included is my name at the top. Thank you for your help in advance!

Name: Samuel GastelWeek 7 iLab—Sales TaxTCO 3: Given a simple problem, design and desk-check a solution algorithm requiring a modulardesign that is expressed in terms of pseudocode or program notes, input-process-output (IPO) analysis,and flow chart.TCO 7:Given a program with logic errors that is intended as a soluTon to a simple problem, employdebugging diagnosTcs to remove and correct the errors.TCO 8: Given a more complex problem, develop a complete solution that includes a comprehensivestatement of the problem, complete program design, and program documentation.ScenarioYour algorithm will write two functions called ComputeTotal( ) and ComputeTax( ).ComputeTotal( ) will receive the quantity of items purchased, and the unit price of each item.It will return the total sales (quantity times price).ComputeTax( ) will receive total sales as a number and the state as a string and return theamount of tax depending on the state.NJrequires 7% tax,FLrequires 6% tax, andNYhas 4% tax.The main program will ask for the name of the customer and read the name in a variablecalledname.It will also ask for one of the three states listed above. It will ask for the numberof items sold and the unit price of the item.Main will then call ComputeTotal( ), passing the quantity and unit price. Main will then callComputeTax( ), passing the state and the amount of sales and receive back the tax. FinallyMain( ) will print out the total sales, the tax amount, and the total with taxes. For example, seebelow.Enter the name of the customer:JackIn which state (NY / NJ / FL) ?NJHow many items were purchased?:3What was the unit price of the items?:1.50The total sales for Jack are $4.50The total with taxes is $4.82Make sure you save the return values into an appropriate variable. Use formattedoutput to make the program more user friendly.Be sure to think about the logic and design first (IPO chart, pseudocode, and flowchart), thencode the C# program.
Background image of page 1
 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"

(TCOs 1, 6) The user of your program chooses one of nine menu items by entering a number between 1 and 9. The best conditional structure to use to implement each menu procedure is _____.(Points : 5)     

(TCOs 1, 6) The user of your program chooses one of nine menu items by

entering a number between 1 and 9. The best conditional structure to use to implement each menu procedure is _____.(Points : 5)

A. a series of IF statements  B. nested IF statements      C. a loop     D. switch

3. (TCOs 1, 6) Because information in _____ is lost when the power is turned off, that type of memory is considered to be _____.(Points : 5)

A. auxiliary storage, nonvolatile   B. auxiliary storage, volatile   C. RAM, nonvolatile  D. RAM, volatile

4. (TCOs 2, 3) Your C# program needs to store a single alphanumeric character the user will enter. When your program starts, the default setting for that character should be the letter A. You implement this functionality by writing _____.

(Points : 5)

A. char myVar = A;    B. char myVar = ‘A’; C. char myVar(‘A’);  D. char myVar(A);

7. (TCO 4) What will be the value of the variable “price” after the following code executes?            int myVal = 2;
int price = 0;
switch(myVal)
{
Case 1: price = 3;
Break;
Case 2: price += 4;
Break;
Case 3: price % 5;
Break;
Default: price = 0;
Break;
}

(Points : 5)

A. 3B. 4C. 5D. 0

9. (TCO 5) In this code, the variable _____ is a counter and the variable _____ is an accumulator.            double sum = 0, height = 2.0, stop =10, max = 50;
int track = 0, num = 0;
while (num <= stop)
{
sum = sum + height * num;
if (sum <= max)
track++;
num++;
}

(Points : 5)

A. num, trackB. sum, trackC. track, sumD. height, stop

10. (TCO 5) In this code, the outer FOR loop executes _____ times.            int i = 1, j = 1;
for (i = 1; i < 4; i++)
{
for (j = 1; j < 4; j++)
{
Console.Write(“{0}{1} “, i, j);
}
}

(Points : 5)

A. threeB. fourC. nineD. 16

 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"