Solved

Payroll Java Help

Posted on 2014-02-22
7
330 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 400 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

622 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