Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Payroll Java Help

Posted on 2014-02-22
7
Medium Priority
?
336 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
  • 3
  • 2
  • 2
7 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 39879027
0
 
LVL 17

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
Industry Leaders: 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 17

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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Suggested Courses

886 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