1 Attachment(s)
Need help with Java Coding
Hello, I am new to Java programming and I have an assignment which I'm very confused on. I attached the assignment and required some help. I don't expect answers, just need some guidance on what to do. For the setUp method, I typed Float Salary; and for the Gross Salary i typed String P1= .64; but it keeps giving me an error. Can anyone give me some pointers on what to do. Thanks.
Attachment 1572
Re: Need help with Java Coding
If you truly need help, please post more of your code in a format that we can read. Also please read the forum FAQ.
Re: Need help with Java Coding
Sorry for the trouble, Here is the following codes I have so far
import com.nyt.exam02.IBonus;
public class Bonus implements IBonus {
protected float salary;
protected String code;
@Override
public float getBonus() {
// TODO Auto-generated method stub
return this.salary;
}
@Override
public float getTaxedBonus() {
// TODO Auto-generated method stub
float TaxedBonus=(float) (this.salary-0.49*this.salary);
return TaxedBonus;
}
@Override
public String getVendorEmail() {
// TODO Auto-generated method stub
String Email= "mhchowdhury90@gmail.com";
return Email;
}
@Override
public void setUp(float salary, String code) {
// TODO Auto-generated method stub
this.salary=salary;
String P1 = null, P2 = null;
if (this.code==P1){
this.salary=salary * 0.64f;
}
else if (this.code==P2){
this.salary=salary*0.60f;
Planning on doing the if else statement for the rest of the Performance Codes. Will this be right or am I doing something wrong. is there an easier way to input all those codes without having to type it all out like that? thanks
Re: Need help with Java Coding
Please wrap your code in the code tags.
What errors you can see?
Also, read the difference about == and .equals() for String comparison.
Re: Need help with Java Coding
PHP Code:
import com.nyt.exam02.IBonus;
public class Bonus implements IBonus {
float _Salary= 0;
@Override
public float getBonus() {
// TODO Auto-generated method stub
int bonus = (this._Salary+ P1);
return 0;
}
float __Salary= 0;
@Override
public float getTaxedBonus() {
// TODO Auto-generated method stub
return 0;
}
@Override
public String getVendorEmail() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setUp(float Salary, String Performance) {
this._Salary= Salary;
this.__Salary= Salary;
double P1= (Salary*.64);
double P2= (Salary*.60);
double P3= (Salary*.56);
double P4= (Salary*.52);
double P5= (Salary*.48);
double P6= (Salary*.44);
double P7= (Salary*.40);
double P8= (Salary*.36);
double P9= (Salary*.32);
double P10= (Salary*.28);
double P11= (Salary*.24);
double P12= (Salary*.20);
double P13= (Salary*.16);
double P14= (Salary*.12);
double P15= (Salary*.8);
double P16= (Salary*.4);
double P17= (Salary*0);
This is what I have so far, I'm not sure how to do the setUp method. It wants me to set up two parameters, the first being the Salary. The second being the Performance Code ( P1= 64%, P2= 60%, etc.) I'm not sure how to approach this problem. The Performance is in String but shouldn't it be in double since I'm using percentage?
Re: Need help with Java Coding
Can you post the full text of the compiler errors you are getting?
You should compile often and fix the errors to keep the number of errors low and easy to fix.