Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Payroll Java Help

Posted on 2014-02-22
7
Medium Priority
?
335 Views
Last Modified: 2014-02-22
Very new to Java and starting to learn,but getting confused along the way ..

Here is what im trying to do -

Write a class that accepts a user's hourly rate of pay and the number of hours worked.
Display the user's gross pay (gross pay = hours worked * hourly rate),
the tax withheld (tax withheld = gross pay * tax rate) and the net pay
(net pay = gross pay - tax withheld).Use a named constant for storing the tax rate of
0.15

Here is my code

import java.util.Scanner;

	class Tutorial
{
	public static void main(String[] args);
	{
	
	Scanner kb = new Scanner(sysem.in);
	
	double = hourlyrate;
	double = hoursworked;
	double = grosspay;
	double = netpay;
	double = taxrate 0.15;
	double = taxwithheld;
	
	System.out.println("Please enter rate of pay?" );
	hourlyrate = kb.nextdouble();
	
	System.out.println("Hours Worked?" );
	hoursworked = kb.nextdouble();
	
	System.out.println("Gross pay:" )+(grosspay = hoursworked*hourlyrate);
	
	System.out.println("Tax Withheld:" )+(taxwithheld= grosspay*taxrate);
	
	System.out.println("netpay:" )+(netpay= Grosspay-taxwithheld);
	
	}
}
	

Open in new window

0
Comment
Question by:JJAus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 39879027
0
 
LVL 16

Accepted Solution

by:
krakatoa earned 1600 total points
ID: 39879051
A few mistakes in there. See if you can tell us what they were and why.

import java.util.Scanner;

	class Tutorial
{
	public static void main(String[] args)
	{
	
	Scanner kb = new Scanner(System.in);
	
	double hourlyrate;
	double hoursworked;
	double grosspay;
	double netpay;
	double taxrate = 0.15;
	double taxwithheld;
	
	System.out.println("Please enter rate of pay?" );
	hourlyrate = kb.nextDouble();
	
	System.out.println("Hours Worked?" );
	hoursworked = kb.nextDouble();
	
	grosspay = hoursworked*hourlyrate;

	System.out.println("Gross pay: " +grosspay);

	taxwithheld= grosspay*taxrate;
	
	System.out.println("Tax Withheld: " +taxwithheld);

	netpay= grosspay-taxwithheld;
	
	System.out.println("netpay: "+netpay);
	
	}
}
	

Open in new window

0
 

Author Comment

by:JJAus
ID: 39879065
Thank you for so much help - My 'variable = ' part, and use of parentheses is incorrect
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:krakatoa
ID: 39879068
Ok.

The other expert in this question has been a long-time bastion of my own learning process. I do hope you read and followed his comment, and really, I'd prefer if you'd split the points between us. Thanks.
0
 

Author Comment

by:JJAus
ID: 39879090
Sorry i accidentally didn't know about point splitting, Thank you so much,,

I'm  just trying to master this site since i am new to the site..
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39879105
Don't worry about points. btw, variable names in Java should be in camel case, beginning lower case
0
 

Author Comment

by:JJAus
ID: 39879784
Very nice info there CEHJ :)
Very Insightful and informative i must say -  i shall do some more study on Java a lot more.
I'm slowly getting there :)

Thanks krakatoa & CEHJ
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video teaches viewers about errors in exception handling.

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question