Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Need help with Java Coding

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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.


    Asn1.pdf


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default 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.

  3. #3
    Junior Member
    Join Date
    Nov 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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

  4. #4
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default 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.
    Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young. The greatest thing in life is to keep your mind young.

    - Henry Ford

  5. #5
    Junior Member
    Join Date
    Nov 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need help with Java Coding

    PHP Code:
    import com.nyt.exam02.IBonus;

    public class 
    Bonus implements IBonus {

        

        
    float _Salary0
        @
    Override
        
    public float getBonus() {
            
    // TODO Auto-generated method stub
            
    int bonus = (this._SalaryP1);
            
            return 
    0;
        }

        
    float __Salary0
        @
    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 SalaryString Performance) {

                
    this._SalarySalary;
            
    this.__SalarySalary;
            
            
    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?

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default 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.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Java Applet Coding Help?
    By Drag01 in forum Java Applets
    Replies: 1
    Last Post: April 26th, 2012, 07:03 AM
  2. java coding
    By deq wan in forum Member Introductions
    Replies: 1
    Last Post: April 14th, 2012, 08:48 AM
  3. Replies: 2
    Last Post: February 19th, 2012, 07:36 AM
  4. Help me in java coding
    By smallmac in forum Java Theory & Questions
    Replies: 5
    Last Post: August 2nd, 2010, 09:50 AM
  5. Java coding help
    By Javalover1 in forum The Cafe
    Replies: 0
    Last Post: April 12th, 2010, 08:11 PM