Create a static variable called numemployees

Assignment Help Programming Languages
Reference no: EM131272178

Assignment

The objective of the lab is to take the UML Class diagram and enhance last week's Employee class by making the following changes:

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.

Increment numEmployees in all of the constructors

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

Capture the Console output window and paste it into a Word document.

Zip the project folder files.

STEP 1: Understand the UML Diagram

Back to Top

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.

STEP 3: Modify the Employee

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

Create a static numEmployees variable and initialize it to zero.

Increment numEmployees by 1 in each of the constructors.

Create an overloaded setDependents method and this time make the parameter a string.

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.

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

Back to Top

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.

Create an Employee object using the default constructor.

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.

Prompt for and then set dependents and annual salary using the new overloaded setters.

Using your code from Week 1, display a divider that contains the string "Employee Information".

Display the Employee Information.

Display the number of employees created using getNumEmployees. Remember to access getNumEmployees using the class name, not the Employee object.

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

Using your code from Week 1, display a divider that contains the string "Employee Information".

Display the employee information for the second Employee object.

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

Back to Top

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.

STEP 6: Screen Prints

Back to Top

Capture the Console output window and paste it into a Word document. The following is a sample program output.

Reference no: EM131272178

Questions Cloud

Discuss pr in relation to research : Outline the kinds of research typical to sales promotion campaigns.-  Discuss PR in relation to research, and in particular image studies, using examples to illustrate.
Business components be accounted for in sustainability plan : How should business components be accounted for in a sustainability plan? Please include an explanation of backup and recovery protocol/procedure along with disaster recovery and a business continuity plan.
Manufacturer of a liquid glass-cleaner : A manufacturer of a liquid glass-cleaner wants to determine the expected sales of its products throughout the country. To help in this project, prepare a report that shows the following information for your city/ town:
Heard several complaints from customers : This month, Alice, the branch manager of Quality Computer Sales, has heard several complaints from customers that Quality employees do not return calls. Today a good customer told Alice that "my phone calls and e-mails are returned after maybe a week..
Create a static variable called numemployees : 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.
Ethical challenges in the global business environment : Many business leaders believe that engaging in global business provides opportunities to expand and stay competitive. Go to "SEC Enforcement Actions: FCPA Cases" found at http://www.sec.gov/spotlight/fcpa/fcpa-cases.shtml.
Affect the pakistan balance of trade : Assignment: Do you think we should buy goods and services that are produced in Pakistan -or foreign/ imported products? Does either practice affect the Pakistan's balance of trade? Discuss in detail.
Why was t. hall singled out for scrutiny : What authority did men claim? What does the struggle to mark T. Hall's gender identity suggest about the structure of community life and the roles of men and women in colonial America?
What if we choose another number for n : For N = 20, what range of scores are possible? How many variables will you need to hold the probability estimates for those scores? What if we choose another number for N?

Reviews

Write a Review

Programming Languages Questions & Answers

  Create program which models snake-s behavior

Create a program which models snake's behavior in the given scenario: A snake is moving toward hole. Each time it moves, snake cuts distance between itself and hole by its own body length

  Discuss the merits and weaknesses of interpreting,compiling

Interpreted code executes much more slowly than compiled code, yet several systems use them extensively. The most well known are Visual Basic (it has two modes: interpreter mode and compiler mode), JavaScript and the special case of interpretation..

  Write complete main method using good programming practices

Write a complete main method using good programming practices when you rewrite the while loop as a do/while loop.

  Create and implement application which reads integer value

Create and implement application which reads the integer value representing a number grade. purpose of the program is to determine corresponding letter grade based on the following grade policy table

  Write a program that takes a single directory as an argument

Write a program that takes a single directory as an argument, and iterates through all the normal files in the directory, and concatenate them to standard out.

  Create application to enter number of units sold

Quantity discounts are given according: create an application that allows the user to enter the number of units sold for each software package.

  How write the program to calculate simple matrix

How to write the program to calculate simple 3x3 spreadsheet containing integers and strings. First, input spreadsheet source values from console.

  Create a program that reads position and velocity data

For this project, you will create a program that reads position, velocity, and acceleration data from a file, and determines if two objects will collide.

  Business rules form the basis of the database design.

A member receives many invitations, and each invitation is sent to many members.

  Write shell script to determine whether given file exist

Write shell script to determine whether given file exist or not, file name is supplied as command line argument, also check for sufficient number of command line argument

  Simmac language programs

Write three programs in the machine language of the SIMMAC that will total the numbers stored in 20 different locations and place the result in a single location.

  What is the output of the following program

What is the output of the following program and please explain it how did you get the answer or the output and the reason. void f(int i ) { if ( i = 4 ll i = 5 )/ Line 1 { cout

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd