IN JAVA
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):
Chris Jacobsen, employee number 11111, made $50.00 in gross
pay.
Using text forming so that the gross pay is rounded to two decimal
places.
import java.util.Scanner;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Vamsi
*/
class Payroll
{
//data members
String name;
int idNumber;
double rate;
int hours;
//methods
//constructor
//takes employe name and id number
Payroll(String Name,int id)
{
this.name = Name;
this.idNumber=id;
}
//accessors//
String getName()
{
return this.name;
}
int getID()
{
return this.idNumber;
}
double getRate()
{
return this.rate;
}
int getHours()
{
return this.hours;
}
//mutators//
void setName(String s)
{
this.name=s;
}
void setID(int i)
{
this.idNumber=i;
}
void setRate(double r)
{
this.rate=r;
}
void setHours(int h)
{
this.hours=h;
}
//method to find grosspay
double GrossPay()
{
return this.hours*this.rate;
}
};
public class Employe {
public static void main(String argv[])
{
String s;
double r;
int id,h;
//to read input
Scanner sc = new Scanner(System.in);
System.out.print("Enter name:");
s = sc.nextLine();
System.out.print("Enter id:");
id =sc.nextInt();
System.out.print("Enter rate:");
r = sc.nextDouble();
System.out.print("Enter hours:");
h = sc.nextInt();
//creating payroll object...
Payroll p = new Payroll(s,id);
p.setHours(h);
p.setRate(r);
System.out.print("You had an employe named "+p.getName());
System.out.print("with ID number "+p.getID());
System.out.print(", who works for "+p.getHours());
System.out.println(" at $"+p.getRate()+"/hr:");
System.out.println(p.getName()+", employee number "+p.getID()+",
made $"+p.GrossPay()+" in gross pay.");
}
}
output:
run:
Enter name:Chris Jacobsen
Enter id:11111
Enter rate:10
Enter hours:5
You had an employe named Chris Jacobsenwith ID number 11111, who
works for 5 at $10.0/hr:
Chris Jacobsen, employee number 11111, made $50.0 in gross
pay.
BUILD SUCCESSFUL (total time: 32 seconds)
Given attached you will find a file from Programming Challenge 5 of chapter 6 with required you to write a Payroll class that calculates an employee’s payroll. Write exception classes for the following error conditions: An empty string is given for the employee’s name. An invalid value is given to the employee’s ID number. If you implemented this field as a string, then an empty string could be invalid. If you implemented this field as a numeric variable, then a...
java Payroll class Exceptions Programming Challenge 5 of Chapter 6 required you to write a Payroll class that calculates an employee’s payroll. Write exception classes for the following error conditions: • An empty string is given for the employee’s name. • An invalid value is given for the employee’s ID number. If you implemented this field as a string, then an empty string would be invalid. If you implemented this field as a numeric variable, then a negative number or...
I would like help and there are three different classes in the
coding..
14.11 Prog11 Inheritance(PayrollOvertime) Create three files to submit: • Payroll class.java -Base class definition • PayrollOvertime.jave - Derived class definition • ClientClass.java - contains main() method Implement the two user define classes with the following specifications: Payroll class (the base class) (4 pts) • 5 data fields(protected) o String name - Initialized in default constructor to "John Doe" o int ID - Initialized in default constructor to...
Suppose you were given the job to write a Java class to manage employee payroll information in an HR management system. Each employee will be modeled as a single EmployeePayroll object (much like the Student objects discussed in class). The state of the EmployeePayroll object includes the first name and last name of the employee, a unique 15 digit employee number for each employee, a number of hours that they've worked this week (which could be a fraction of an...
C++ Program The Ward Bus Manufacturing Company has recently hired you to help them convert their manual payroll system to a computer-based system. Write a program to produce a 1-week payroll report for only one employee to serve as a prototype (model) for the administration to review. Input for the system will be the employee’s 4-digit ID number, the employee’s name, hours worked that week, and the employee’s hourly pay rate. Output should consist of the employee’s ID number, the...
Payroll Application Problem Description: An org needs a payroll application which has the capability to calculate and print the monthly pay of an employee. The application starts by printing a short description of what it does. Then, it asks for the employee name. Next, the application prompts for employee type (“H” for hourly and “S” for salaried.) If the user enters S, the gross pay is set to $4000. However, if the user enters H for an hourly employee, the...
With Java Language:
In this assignment, you are to create a class named Payroll. In the class, you are to have the following data members: name: String (5 pts) .İd: String (5 pts) hours: int (5 pts) rate: double (5 pts) private members (5 pts) You are to create no-arg and parameterized constructors and the appropriate setters(accessors) and getters (mutators). (20 pts) The class definition should also handle the following exceptions: An employee name should not be empty, otherwise an...
Create a C# Console program. Add a class named Employee that has the following public fields: • Name. The name field references a String object that holds the employee’s name. • IDNumber. The IDNumber is an int that holds the employee’s ID number. • Department. The department field is a String that holds the name of the department where the employee works. • Position. The position field is a String that holds the employee’s job title. Once you have written...
It must be C++
Chapter 13 Programming Challenge 2: Employee Class.
See instruction: Chapter 13 Programming Challenge 2 Employee
Class.pdf
Program Template:
// Chapter 13, Programming Challenge 2: Employee Class
#include <iostream>
#include <string>
using namespace std;
// Employee Class Declaration
class Employee
{
private:
string name; // Employee's name
int idNumber; // ID number
string department; // Department name
string position; // Employee's position
public:
// TODO: Constructors
// TODO: Accessors
// TODO: Mutators
};
// Constructor #1
Employee::Employee(string...
The following needs to be in C programming ! Outcomes: Demonstrate the ability to design a menu driven program. Demonstrate the ability to reuse previous code to create a new assignment. Demonstrate the ability to use appropriate program logic. Program Specifications: DESIGN and IMPLEMENT a menu driven program that uses the following menu and can perform all menu items: Enter a payroll record for one person Display all paycheck stubs Display total gross payroll from all pay records. Quit program...