Solved

Payroll Java Help

Posted on 2014-02-22
7
322 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 Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
eclipse buid path vs tomcat lib path 10 34
ejb entity bean example issue 2 18
Link failure 16 36
learn programming 8 42
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This article will show, step by step, how to integrate R code into a R Sweave document
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

821 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