Question: Need Java Help... Payroll Class Design a Payroll class with the following fields: name: a String containing the employee's name idNumber: an int representing the

Need Java Help... Payroll Class Design a Payroll class with the following fields: name: a String containing the employee's name idNumber: an int representing the employee's ID number rate: a double containing the employee's hourly pay rate hours: an int representing the number of hours this employee has worked The class should also have the following methods: Constructor: takes the employee's name and ID number as arguments Accessors: allow access to all of the fields of the Payroll class Mutators: let the user assign values to the fields of the Payroll class grossPay: returns the employee's gross pay, which is calculated as the number of hours worked times the hourly pay rate. Write another program that demonstrates the class by creating a Payroll object, then asking the user to enter the data for an employee in the order: name, ID number, rate, hours. The program should then print out a statement in the following format (for example, if you had an employee named Chris Jacobsen with ID number 11111, who works for 5 hours at $10/hr): *****Desired Output****** Chris Jacobsen, employee number 11111, made $50.00 in gross pay. ***********Here is my problem********

1) I can not input a first AND last name I can input the first name and it works just fine but as soon as I input a space and last name everything breaks loose and the program loses its mind.

2) I only have 1 decimal place for the $ earned... I need 2

**********Here is my code*********

import java.util.Scanner;

public class PayrollTest { public static void main(String args[]) {

Scanner scan = new Scanner(System.in); Payroll Pay = new Payroll(); System.out.println("Enter the Employee's Name : " ); String s = scan.next(); Pay.setName(s); System.out.println("Enter the Employee's Id : "); int i0 = scan.nextInt(); Pay.setIdNumber(i0); System.out.println("Number of hours worked : "); int i = scan.nextInt(); Pay.setHours(i); System.out.println("Hourly pay rate in $ : "); double d = scan.nextDouble(); Pay.setRate(d); double Total_GrossPay = Pay.calcGrossPay(); System.out.println(""); System.out.println(""); System.out.println(""+Pay.getName() +","+""+"employee number "+Pay.getIdNumber() +","+ " " +"made $"+Total_GrossPay +" " +"in gross pay."); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!