Click to See Complete Forum and Search --> : Java code


mkanya
March 16th, 2008, 12:06 PM
May anyone please help me solve the following:

QUESTION 1

FeedEx founded in 2001, operates a delivery service. The company wants you to write an object oriented program for scheduling deliveries.

Create a Delivery class that contains fields to hold the following:

1. A delivery number that contains six digits assigned as follows:
a. The first digit represents the year; the company’s first year, 2001 is 1. For example, for deliveries made in 2005, the first digit for all deliveries is 5.
b. The second and third digits represent the month. For example, a delivery in March 2005 begins with 503.
c. The last three digits represent the delivery number. For example, the 86th delivery in March 2005 has a complete delivery number 503086.
2. A code representing the delivery area as follows:
a. 1-Local
b. 2-Long Distance
3. A weight, in pounds, of the item to be delivered.
4. The fee for the delivery, as follows:

Distance Area Code Weight Fee
1 Under 5 pounds 12.00
1 5 to 20 pounds 16.50
1 Over 20 pounds 22.00
2 Under 5 pounds 35.00
2 5 pounds or more 47.95

Create a constructor for the Delivery class that accepts arguments for the year, month, and delivery number within the month, delivery distance code and weight of the package. The constructor determines the six-digit delivery number and delivery fee. Also include a method that displays every Delivery object field.

Create an application that prompts the user for the data for a delivery. Keep prompting the user for each of the following values until they are valid:
• A four-digit year between 2001 and 2009 inclusive
• A month between 1 and 12 inclusive
• A delivery number for the month between 1 and 999 inclusive
• A package weight between 0.10 pound and 100 pounds inclusive
• A delivery distance code that either 1 or 2
When all the data entries are valid, construct a Delivery object, and then display its values.


QUESTION 2

The GoGoTax Company provides free tax preparation service to people who need help calculating their personal taxes. You have been asked to write a Java application that will calculate an estimated tax for a taxpayer, based on keyboard response.

Create a TaxReturn class with fields that holds taxpayer’s Social Security number, last name, first name, street address, city, zip code, annual income, martial status, and tax liability. Include a constructor that requires arguments that provides values or all fields other than the tax liability. The constructor calculates the tax liability based on annual income and the percentages in the following table

Marital Status
Income Single Married
0-20,000 15% 15%
20,0001-50,000 22% 20%
50,001 and over 30% 28%

In the TaxReturn class, also include a display method that displays all the TaxReturn data.

Also, create an application that prompts a user for the data needed to create a TaxReturn. Continue to prompt the user data as long as any of the following are true:
• The social security number is not in the correct format, with digits and dashed in the appropriate positions; for example, 999-99-9999.
• The zip code is not five digits.
• The marital status does not begin with one of the following “S”,”s” ,”M” ,or “m”
• The annual income is negative

After all the input data is correct, create a TexReturn object and then displays its values.


QUESTION 3

Nuts & Bolt Private Limited runs a small factory that makes several types of nuts and bolts. The company employs factory workers who are paid one of there hourly rates depending on skill level:

Skill Level Hourly Pay Rate
1 17.00
2 20.00
3 22.00

Each factory worker might work any number of hours per week; any hours over 40 are paid at one and one-half times the usual rate.

In addition, workers in skill levels 2 and 3 can elect the following insurance options:

Option Explanation Weekly Cost to Employee
1 Medical Insurance RM32.50
2 Dental Insurance RM20.00
3 Long Term disability Insurance RM10.00

Also, workers in skill level 3 can elect participate in the retirement plan at 3% of their gross pay.

Allen wrench, the factory manager, wants you to write an interactive Java payroll application that calculates the gross pay for a factory worker. The program prompts the user for skill level and hours worked, as well as appropriate insurance and retirement options for the employee’s skill level category. The application display:
1. The hours worked
2. The hourly pay rate
3. The regular pay for 40hours
4. The overtime pay
5. The total of overall and regular time pay
6. Total itemized deduction. If the deductions exceed the gross pay, display an error message; otherwise calculate and display
7. The net pay after all the deductions has been subtracted from the gross.

dlorde
March 16th, 2008, 03:37 PM
We'd be happy to help. Post up the code you have so far (put the [CODE]...[/CODE] tags around it), and explain exactly where you are stuck or what you don't understand.

No-one is going to do it for you, but we'll help you if you are prepared to do the work.

The truth is, when all is said and done, one does not teach a subject, one teaches a student how to learn it. Teaching may look like administering a dose, but even a dose must be worked on by the body if it is to cure. Each individual must cure his or her own ignorance...
J. Barzun