PDA

View Full Version : Simple Java Program...Need some coding help


cfredericks
09-07-2005, 05:19 PM
I am a beginner programmer and found this fairly easy program but im so new to java that i cant figure the coding out. If anybody could help this would be awesome! I would even pay someone to code this for me and put it into file. Thanks, cole. :cool: :thumbsup:


Write a program that calculates and prints the monthly pay check for an employee. The net pay is calculated after taking the following deductions:

Federal Income Tax: 15%
State Tax: 3.5%
Social Security Tax: 5.75%
Medicare/Medicaid Tax: 2.75%
Pension Plan: 5%
Health Insurance: $75.00

Your program should prompt the user to input the employee name and the gross amount. The out put will be stored in a file. Format your output to two decimal places. A sample output follows.

Allison Nields
Gross Amount: $3575.00
Federal Tax: $536.25
State Tax: $125.13
Social Security Tax: $205.56
Medicare/Medicaid Tax: $98.31
Pension Plan: $178.75
Health Insurance: $75.00
Net Pay: $2356.00

:) :D :thumbsup:

nikkiH
09-07-2005, 06:26 PM
I believe there is a thread about how homework needs to be done by you. We're not doing anyone any favors by doing it for you.

Give it a shot, post what you have and specific questions and I'm sure we'd love to help out.

Simple beginner how to read from console and read/write files here:
http://www.ipwebdesign.net/help_java.html

cfredericks
09-07-2005, 07:05 PM
public class Income{
private final double FEDERAL = 0.15;
private final double STATE = 0.035;
private final double SOCIAL_SECURITY = 0.0575;
// etc...


public double calculate_income(double raw_val){
return (raw_val- getFederal(raw_val) - getState(raw_val));// etc...
}

public double getFederal(double val){
return val * FEDERAL;
}

public double getState(double val){
return val * STATE;
}

// etc...
}

Alright, well heres a start i got about a half hour ago, anybody got any suggestions about taking this further....

nikkiH
09-07-2005, 08:07 PM
You need to be more organized or you'll end up churning.
Take your requirements and make comments that are pseudocode. Then start writing code to make it work.

Example:
Write a program that calculates and prints the monthly pay check for an employee. The net pay is calculated ...
Your program should prompt the user to input the employee name and the gross amount. The out put will be stored in a file. Format your output to two decimal places. A sample output follows.

By definition, this will run in Main. So start there. Then look at what you need to support it.
Coding that way will make it easier for you to learn about other OOP concepts like encapsulation, data hiding, and such later.


public static void main (String[] args)
{
// prompt user to input employee name

// prompt user to input gross pay

// calculate net pay

// output all data to file
}



Tackle each of those separately. You don't need the getters you wrote unless your teacher asked you to write two separate classes. The calculations are all done in this class.
When you advance more and have classes calling methods of other classes, you do setters and getters, but no other class needs to get federal, etc, so no need to expose them.


I saw your get syntax and assumed getters. Sorry. My bad.
Don't name methods like that. You'll see why later when you get to more advanced Java. Don't say getXXX or setXXX unless the method gets or sets. It's just a language convention that many (most?) java coders use to indicate getters and setters of object private properties. The syntax is required, actually, for things like NetBeans.

aal300m
05-28-2006, 09:42 PM
hello
I am a beginner in java programing and i have a little problem coding I need some help here is my situation TaxWhiz that computes the sales tax for a purchase. It should store the currect tax rate as an instance variable. This class should have one public method, calcTax(double purchase), which returns a double, show value is purchases time the tax rate.