Having trouble understanding what my instructor wants me to do, and hobasically not understanding the project
16 Replies - 2591 Views - Last Post: 12 March 2010 - 02:25 PM
#1
Having trouble understanding what my instructor wants me to do, and ho
Posted 11 March 2010 - 02:43 PM
{Create a class named Pay that includes five double variables that hold hours worked, rate of pay per hour, withholding rate, gross pay, and net pay. Create three overloaded computeNetPay() methods. When computeNetPay() receives values for hours, pay rate, and withholding rate, it computes the gross pay and reduces it by the appropriate withholding amount to produce the net pay.(Gross pay is computed as hours worked multiplied by pay per hour.) When computeNetPay() receives two parameters, they represent the hours and pay rate, and the withholding rate is assumed to be 15%. When computeNetPay receives one parameter, it represents the number of hours worked, the withholding rate is assumed to be 15%, and the hourly rate is assumed to be 5.85. Write a main() method that tests all three overloaded methods. Save the application as Pay.java.}
I read this at least 6 times and I still have no clue what she really wants...Is there any possible way maybe someone a little smarter than me could clarify this project for me???
Replies To: Having trouble understanding what my instructor wants me to do, and ho
#2
Re: Having trouble understanding what my instructor wants me to do, and ho
Posted 11 March 2010 - 02:46 PM
#3
Re: Having trouble understanding what my instructor wants me to do, and ho
Posted 11 March 2010 - 03:27 PM
Unfortunately if you cannot provide some sort of code we cant help you out as much but we can encourage you in helping you understand the assignment
There will be a class called Pay.
It will have five double type variables.
Create three overloaded computeNetPay() methods.
Overloaded methods will have different signatures within their parameters
For example void computeNetPay(double a) and void computeNetPay(double a, double c) --this is just an example of overloading methods--
This is how methods with the same name are identified.
computeNetPay() will have three method versions
computeNetPay(1st signature,2nd signature,3rd signature)
computeNetPay(1st signature,2nd signature)
computeNetPay(1st signature)
Each method will do certain tasks.
You then have a main() method
you then create an object of the Pay class and call these methods with the variables you have declared the object as.
Hope that has helped you.
This post has been edited by m-e-g-a-z: 11 March 2010 - 03:38 PM
#4
Re: Having trouble understanding what my instructor wants me to do, and ho
Posted 11 March 2010 - 04:11 PM
#5
Re: Having trouble understanding what my instructor wants me to do, and ho
Posted 11 March 2010 - 04:21 PM
#6
Re: Having trouble understanding what my instructor wants me to do, and ho
Posted 11 March 2010 - 07:01 PM
Here is the code I have written so far...
public class Pay
{
double hoursWorked
double ratePayPerHour
double withholdingRate
double grossPay
double netPay
public static void main(String[] args)
{
}
public static void computeNetPay(double hoursWorked, double ratePayPerHour, double withHoldingRate)
{
grossPay = (hoursWorked * ratePayPerHour)
}
}
I hope I am doing this right, I really wanna learn more about java programming, I'm just not sure I have the intelligence for it.
This post has been edited by kweef19: 11 March 2010 - 07:02 PM
#7
Re: Having trouble understanding what my instructor wants me to do, and ho
Posted 11 March 2010 - 07:12 PM
class Example {
// A no-argument implementation
public void dudMethod(){
// Our method goes here
}
public void dudMethod(int number) {
// Method here
}
public void dudMethod(int number, String string) {
// Method here
}
public void dudMethod(String string) {
// Method here
}
}
See? All are called dudMethod, but each takes different variable types/numbers. Now, when you call these methods, you simply pass the needed arguments into it. If we wanted to call the second one for example (it takes an int), we could do it like this:
dudMethod(3);
Or to call the 3rd (an int and a String):
dudMethod(3, "three");
Or even number 4 (just the String):
dudMethod("Three);
Get it?
#8
Re: Having trouble understanding what my instructor wants me to do, and ho
Posted 11 March 2010 - 09:43 PM
public class Pay
{
double hoursWorked
double ratePayPerHour
double withholdingRate
double grossPay
double netPay
public static void main(String[] args)
{
}
public void computeNetPay(double hoursWorked, double ratePayPerHour, double withHoldingRate)
{
grossPay = (hoursWorked * ratePayPerHour);
netPay = (grossPay * withholdingRate);
System.out.println("the rate of pay per hour is " + ratePayPerHour);
System.out.println("This paycheck is based on " + hourWorked + "hours worked ");
System.out.println("gross pay is " + grossPay);
System.out.println("After the withholding rate is factored in " + netPay + "is your net pay");
System.out.println("the withholding rate for this computation is " + withholdingRate);
}
public void computeNetPay(double hoursWorked, double ratePayPerHour)
{
withholdingRate = .15;
grossPay = (hoursWorked * ratePayPerHour);
netPay = (grossPay * withholdingRate);
System.out.println("the rate of pay per hour is " + ratePayPerHour);
System.out.println("This paycheck is based on " + hourWorked + "hours worked ");
System.out.println("gross pay is " + grossPay);
System.out.println("After the withholding rate is factored in " + netPay + "is your net pay");
System.out.println("the withholding rate for this computation is " + withholdingRate);
}
public void computeNetPay(double hoursWorked)
{
withholdingRate = .15;
ratePayPerHour = 5.85;
grossPay = (hoursWorked * ratePayPerHour);
netPay = (grossPay * withholdingRate);
System.out.println("the rate of pay per hour is " + ratePayPerHour);
System.out.println("This paycheck is based on " + hourWorked + "hours worked ");
System.out.println("gross pay is " + grossPay);
System.out.println("After the withholding rate is factored in " + netPay + "is your net pay");
System.out.println("the withholding rate for this computation is " + withholdingRate);
}
}
If I made some mistakes, which I'm sure I did, that's not really the point. I am just trying to make sure that I understand the general idea of overloading methods, but any corrections on mistakes would be greatly appreciated.
I love you guys
#9
Re: Having trouble understanding what my instructor wants me to do, and ho
Posted 11 March 2010 - 09:52 PM
kweef19, on 11 March 2010 - 08:43 PM, said:
public class Pay
{
double hoursWorked
double ratePayPerHour
double withholdingRate
double grossPay
double netPay
public static void main(String[] args)
{
}
public void computeNetPay(double hoursWorked, double ratePayPerHour, double withHoldingRate)
{
grossPay = (hoursWorked * ratePayPerHour);
netPay = (grossPay * withholdingRate);
System.out.println("the rate of pay per hour is " + ratePayPerHour);
System.out.println("This paycheck is based on " + hourWorked + "hours worked ");
System.out.println("gross pay is " + grossPay);
System.out.println("After the withholding rate is factored in " + netPay + "is your net pay");
System.out.println("the withholding rate for this computation is " + withholdingRate);
}
public void computeNetPay(double hoursWorked, double ratePayPerHour)
{
withholdingRate = .15;
grossPay = (hoursWorked * ratePayPerHour);
netPay = (grossPay * withholdingRate);
System.out.println("the rate of pay per hour is " + ratePayPerHour);
System.out.println("This paycheck is based on " + hourWorked + "hours worked ");
System.out.println("gross pay is " + grossPay);
System.out.println("After the withholding rate is factored in " + netPay + "is your net pay");
System.out.println("the withholding rate for this computation is " + withholdingRate);
}
public void computeNetPay(double hoursWorked)
{
withholdingRate = .15;
ratePayPerHour = 5.85;
grossPay = (hoursWorked * ratePayPerHour);
netPay = (grossPay * withholdingRate);
System.out.println("the rate of pay per hour is " + ratePayPerHour);
System.out.println("This paycheck is based on " + hourWorked + "hours worked ");
System.out.println("gross pay is " + grossPay);
System.out.println("After the withholding rate is factored in " + netPay + "is your net pay");
System.out.println("the withholding rate for this computation is " + withholdingRate);
}
}
If I made some mistakes, which I'm sure I did, that's not really the point. I am just trying to make sure that I understand the general idea of overloading methods, but any corrections on mistakes would be greatly appreciated.
I love you guys
So far so good, Just one thing, To make it compilable you need to add colons (';') at the end of all your attributes/variables.
double hoursWorked;
double ratePayPerHour;
double withholdingRate;
double grossPay;
double netPay;
#10
Re: Having trouble understanding what my instructor wants me to do, and ho
Posted 11 March 2010 - 10:21 PM
btw, I am now converted...DOGSTOPPER is not just a mentor, he is also my idol. Also lots of thanks goes to tectonic for taking over where dogstopper left off.
This post has been edited by kweef19: 11 March 2010 - 10:22 PM
#11
Re: Having trouble understanding what my instructor wants me to do, and ho
Posted 11 March 2010 - 11:34 PM
Here's what we have so far:
computeNetPay(double), double), double)
computeNetPay(double, double)
computeNetPay(double)
By having 3 unique signatures, this allows up to choose which of the 3 overloaded methods are called, based on what parameters are passed in. For example, the signature of the 3rd overload dictates that it requires one value of type double. Thus, we can call that method with the following code:
computeNetPay(42.0);
Likewise, passing in 2 doubles will call the 2nd overload, and 3 doubles will call the first.
#12
Re: Having trouble understanding what my instructor wants me to do, and ho
Posted 12 March 2010 - 04:28 AM
kweef19, on 12 March 2010 - 12:21 AM, said:
btw, I am now converted...DOGSTOPPER is not just a mentor, he is also my idol. Also lots of thanks goes to tectonic for taking over where dogstopper left off.
Lol Thanks! I can help as soon as I get home today. Oh, and by the way, thanks for the feedback...but I'm just a mentor and I'm still learning much. Thanks though.
#13
Re: Having trouble understanding what my instructor wants me to do, and ho
Posted 12 March 2010 - 07:00 AM
Write a main() method that tests all three overloaded methods. Save the application as Pay.java.
Basically... it wants you to create an object of type pay....
public static void main(String[] args) {
//calls the method using one param
computeNetPay(double);
//calls the method using two params
computeNetPay(double, double);
//calls the method using three params
computeNetPay(double, double, double);
}
This should be pretty much what you professor/teach wants. I'll leave it to you to replace the word double with the values that you want to send to the methods.
- Zach
EDIT: Fixed stupid mistakes. Much thanks Tsunami
This post has been edited by Simple_Condolences: 12 March 2010 - 07:37 AM
#14
Re: Having trouble understanding what my instructor wants me to do, and ho
Posted 12 March 2010 - 07:16 AM
Simple_Condolences, on 12 March 2010 - 06:00 AM, said:
Write a main() method that tests all three overloaded methods. Save the application as Pay.java.
Basically... it wants you to create an object of type pay....
public static void main(String[] args) {
Pay p = new Pay(); //this is a pay object
/**I also noticed, you've no pay constructor...
*Are you supposed to have one? I couldn't
*tell from the assignment so double check that
**/
//calls the method using one param
p.computeNetPay(double);
//calls the method using two params
p.computeNetPay(double, double);
//calls the method using three params
p.computeNetPay(double, double, double);
}
This should be pretty much what you professor/teach wants. I'll leave it to you to replace the word double with the values that you want to send to the methods.
- Zach
The main() method is created within class Pay. The 3 overloads can be called directly without creating a new Pay object.
#15
Re: Having trouble understanding what my instructor wants me to do, and ho
Posted 12 March 2010 - 07:34 AM
- Zach
|
|

New Topic/Question
Reply




MultiQuote










|