Solved

Payroll Java Help

Posted on 2014-02-22
7
318 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 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

This article will show, step by step, how to integrate R code into a R Sweave document
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This video teaches viewers about errors in exception handling.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now