473,804 Members | 3,037 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help with employee class

15 New Member
here are a couple of questions i tried doing but not sure if they are correct. if anyone could please help with with them that would be great.. thanks


An Employee will have a name, social security number, position, and hourly wages. Define the instance data for this class

Answer:

employeeName=na me;
employeePositio n=position;
hourlyWage=wage ;
socialSecurityN umber=ssn;

Write a method that is passed the int value of the number of hours worked for the week as a parameter, and returns the pay for the Employee (including overtime, which is 1.5 * hourly wages for each hour over 40).

Answer:

public double pay (double hours)
{
if(hours<=40)
pay=hours*wage;
else
pay=1.5*wage*ho urs;
return pay;
}

Write a raise method that is passed an increase (or decrease) in hourly wages and updates the Employee’s hourly wages appropriately. The amount passed is strictly the amount of increase or decrease, not a new hourly wage. If the amount of increase (or decrease) is too much (more than what the Employee currently makes) do not adjust the hourly wage, but instead output a warning message.

Answer:// this one im not sure about

public rasie(double increase, double decrease)
{
if(decrease<=Ma th.abs(wage))
System.out.prin tln("Warning amount is less than what employee makes");
else
raise=increase+ wage;
}
Jan 6 '07 #1
1 5759
r035198x
13,262 MVP
here are a couple of questions i tried doing but not sure if they are correct. if anyone could please help with with them that would be great.. thanks


An Employee will have a name, social security number, position, and hourly wages. Define the instance data for this class

Answer:

employeeName=na me;
employeePositio n=position;
hourlyWage=wage ;
socialSecurityN umber=ssn;

Write a method that is passed the int value of the number of hours worked for the week as a parameter, and returns the pay for the Employee (including overtime, which is 1.5 * hourly wages for each hour over 40).

Answer:

public double pay (double hours)
{
if(hours<=40)
pay=hours*wage;
else
pay=1.5*wage*ho urs;
return pay;
}

Write a raise method that is passed an increase (or decrease) in hourly wages and updates the Employee’s hourly wages appropriately. The amount passed is strictly the amount of increase or decrease, not a new hourly wage. If the amount of increase (or decrease) is too much (more than what the Employee currently makes) do not adjust the hourly wage, but instead output a warning message.

Answer:// this one im not sure about

public rasie(double increase, double decrease)
{
if(decrease<=Ma th.abs(wage))
System.out.prin tln("Warning amount is less than what employee makes");
else
raise=increase+ wage;
}



Expand|Select|Wrap|Line Numbers
  1.  
  2. public class Employee {
  3.  //I think they also wanted the data types
  4.  String name;
  5.  String socialSecurityNumber;
  6.  String position;
  7.  double hourlyWages;
  8.  double pay;
  9.  public Employee(String name, String ssn, String pos, double hWages) {
  10.   this.name = name;
  11.   socialSecurityNumber = ssn;
  12.   position = pos;
  13.   hourlyWages = hWages;
  14.  }
  15.  public double getPay(double hours) {
  16.   double overtimeHours = 0.0;
  17.   if(hours > 40) {
  18.    overtimeHours = hours - 40;
  19.   }
  20.   pay = hours * hourlyWages;
  21.   pay = pay + overtimeHours * hourlyWages * 1.5;
  22.   return pay;
  23.  }
  24.  public void raise(double amount) {
  25.   if(Math.abs(amount) > pay) {
  26.    System.out.println("Warning amount is greater than what employee makes");
  27.   }
  28.   else {
  29.    hourlyWages = hourlyWages + amount;
  30.   }
  31.  }
  32. }
Jan 7 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
3790
by: Jonas Cord | last post by:
Hi, I'm trying to learn proxy classes in C++ so I've written the following code, trying to modify an example given in Deitel & Deitel's C++ book. I am trying to "hide" details of the original class (employee.h) through a proxy class (employeeproxy.h). What am I doing wrong? Please help... I will be grateful forever. employee.h ----------
5
2186
by: Zambien | last post by:
Hi all, Here's my problem. I have tables that are using the menu/submenu idea for hiding rows. This works fine in IE (of course) and does show/hide correctly in netscape, but as soon as the shown method is called, the table gets skewed and the presentation of the data on the page goes horribly wrong. I don't think this is a table issue as I have spent alot of time staring at this code. Here is the html...
7
3624
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title> </head> <style type="text/css">
12
5343
by: Noel | last post by:
Hello, I'm currently developing a web service that retrieves data from an employee table. I would like to send and retrieve a custom employee class to/from the webservice. I have currently coded the custom employee class and have built it as a separate library (employee.dll). This employee.dll is being referenced by both the web service and the windows application. I face the following problem when I send this class to the webservice.
6
1344
by: mopicus | last post by:
hello all, i have two base classes, one inherits from bindinglist<> i need baseobject contains a generic reference to collection that contains it class baseobject<T> : where T:baseobjectcollection<baseobject<T>> class baseobjectcollection<T> : BindingList<T> where T:baseobject<baseobjectcollection<T>> i'm getting compile error with this. i'm not sure if it's a syntax error or what i'm trying it's impossible, without generics of...
0
1228
by: jhhbr549 | last post by:
Need to write a class called Sales that is extends from a super class called Employee. I feel like I am going in the wrong direction. look at this: Here are the specs: static double field values - BEST_COMMISSION, HIGH_COMMISSION, HIGH_SALES, LOW_COMMISSION,LOW_SALES, QUOTA_COMMISION, QUOTA_SALES. I believe I have the main constructor correct? Method - getCommissionRate( )
10
7664
by: ycg0771 | last post by:
I'm trying to modify the following program so that it uses a class to store and retrieve the employee's name, the hourly rate, and the number of hours worked. Use a constructor to initialize the employee information, and a method within that class to calculate the weekly pay. It seems that the more I read into this, the more confused I get. Any help will be greatly apreciated. Here is my latest code... // Payroll program that...
1
1763
by: tikney5 | last post by:
I need to modify my current program so that is uses a class to store and retrieve the employees name, hourly rate, and number of hourse worked. Use a constructor to initialize the employee information, and a method within that class to calculate the weekly pay. Once stop is entered as the employee name the application should terminiate. Below is my previous code and some of what I think I need for this assignment. Any help would be great....
7
2060
by: bhipwell via AccessMonster.com | last post by:
Hello, I have developed an employee benefits database that currently contains over 3000 employees and 70+ companies. Having started the database as a really simple solution for our clients, the last six months have demanded more complexity and thus much of the recent work has been patch work to say the least. I finally hit the "too many fields defined error" and now is the time to go back and rebuild part of the database resulting from...
2
2230
by: TeeTea02 | last post by:
Create a class called Employee. An Employee should have four pieces of information as instance variables – first name (type String), last name (type String), monthly salary (type double), and dependents(type int). Your class should have a constructor that initializes the four instance variables. Provide a get and set method for each instance variable. In addition, provide a method named getAnnualSalary that determines the annual salary of the...
0
9579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10326
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10075
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9143
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6851
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5520
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.