473,405 Members | 2,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Weekly Pay Program

[/quote][/HTML]How do I get the variable "nPay" to give me a result?


[quote]
import java.util.Scanner;

public class WeeklyPay1
{


public static void main(String[] a)
{
String name; //Employee's name
String input; //Holds additional kb info
char married; //Married? y or n
char health; //Healthcare? y or n
double hours; //Hours worked by employee
double gPay; //Gross pay
double nDep; //Number of Dependents
double TaxPay; //Income that is taxable
double Taxes; //Holds tax rate for taxable pay
final double marDed= 150; //Standard Deductions for married
final double sDed = 75; //Standard Deductions for single
final double mMed=100; //Medical deductions for married
final double sMed=60; //Medical deductions for single
double nPay; //Employees Net Pay


Payroll1 getpaid = new Payroll1();

Scanner kb = new Scanner(System.in);


//Get the Employee's marital status
System.out.print("Are you Married? Y or N: ");
input = kb.nextLine();
married = input.charAt(0);

//Do you have Healthcare?
System.out.print("Do you have Healthcare: Y or N: ");
input = kb.nextLine();
health = input.charAt(0);

//Get Employee's name
System.out.print("Enter your name: ");
name = kb.nextLine();

//Get Employee's Pay Rate
System.out.print("Enter pay rate: ");
rate = kb.nextDouble();


//Get Employee's hours worked
System.out.print("Enter the number of hours you worked: ");
hours = kb.nextDouble();


//Get Employee's dependents
System.out.print("How many dependents do you have: ");
nDep = kb.nextDouble();

//Store the data
getpaid.setPayRate(rate);
getpaid.setHrsWorked(hours);
getpaid.setDependents(nDep);


//Determine if married, and determine tax bracket
if(married == 'Y' || married == 'y')
{
//Calculate taxable pay
TaxPay = getpaid.getGrossPay()- marDed - (70 * getpaid.getDependents());

if (health == 'Y' || health == 'y')

TaxPay = TaxPay - 100;

if(TaxPay > 800)

Taxes = (TaxPay - 800) * .35 + (800 - 500) * .25 + (500 - 200) * .15 + 200 * .10;

else if (TaxPay > 500)

Taxes = (TaxPay -500) * .25 + (500-200) * .15 + 200 * .10;

else if (TaxPay > 200)

Taxes = (TaxPay -200) * .15 + 200 * .10;

else

Taxes = (TaxPay * .10);
}

else
{
TaxPay = getpaid.getGrossPay() - sDed - (70 * getpaid.getDependents());


if(health == 'N' || health == 'n')

TaxPay -= 60;

if (TaxPay > 400)

Taxes = (TaxPay - 400) * .35 + (400 - 250) * .25 + (250 -100) * .15 + 100*.10;

else if (TaxPay > 250)

Taxes = (TaxPay - 250) * .25 + (250 - 100) * .15 + 100 * .10;

else if (TaxPay > 100)

Taxes = (TaxPay - 100) * .15 + 100 * .10;

else

Taxes = TaxPay * .10;
}

nPay = getpaid.getGrossPay() - mMed; // - Taxes;
System.out.println("Net Pay " + nPay);
}
}
}
}
May 18 '07 #1
1 1613
nomad
664 Expert 512MB
It seem you have several errors in your project

What does rate do?
I don't see a data type for it. it should be a double

These have no data types. These method are undefined for the type WeeklyPay
//Store the data
getpaid.setPayRate(rate);
getpaid.setHrsWorked(hours);
getpaid.setDependents(nDep);

Payroll1 getpaid = new Payroll1(); should be unless you have another class
WeeklyPay getpaid = new WeeklyPay();

Last thing. your cal. might be wrong, remember any thing in Bracket are done first... Review on how do do cal and in what order they are complied at.
nomad
May 18 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Cameron Laird | last post by:
QOTW: "The lesson for me is to spend much less time on Python discussion and much more on unfinished projects. So even if I never use the new syntax, I will have gained something ;-)" - Terry...
0
by: Cameron Laird | last post by:
ANNOUNCEMENT: we had an incident with backups of the "Python-URL!" mailing list. It's possible we lost one or two transactions from the last week. If you aren't receiving an e-mailed copy of...
0
by: Cameron Laird | last post by:
QOTW: "In short, it's never what you think it is ;-)" - timbot, probably on the subject of performance "Real efficiency comes from elegant solutions, not optimized programs. Optimization is...
1
by: Cameron Laird | last post by:
QOTW: "sing Python is not programming, it IS a fun!" - Tolga "The reason for making complex a builtin is _not_ to ease a single program, but to create a convention allowing different modules...
0
by: Cameron Laird | last post by:
QOTW: "I can't say enough about Python and agile programming. Piecing together small, well-documented, well-tested pieces of software makes solving big problems easier." - Shannon Behrens of...
0
by: Gabriel Genellina | last post by:
QOTW: "edundant/useless/misleading/poor code is worse than wrong." - Michele Simionato http://groups.google.com/group/comp.lang.python/msg/74adbb471826a245 "Unit tests are not a magic wand that...
0
by: Gabriel Genellina | last post by:
QOTW: "If you really want to learn hard-core Python, probably your best bet is: * read everything Tim Peters has ever written in comp.lang.python (this will take a few months), start with "import...
0
by: Gabriel Genellina | last post by:
QOTW: " is not just some stupid thing." - Alan Runyan http://wiki.python.org/moin/buildout has more background sum() doesn't use the best possible algorithm when dealing with floating point...
0
by: Gabriel Genellina | last post by:
QOTW: "With Python, you can program with a smile on your face." - Gary Herron "Looking back over the years, after I learned Python I realized that I never really had enjoyed programming before."...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.