Salary 1500...



  • I asked a student to write a Function if Salary is greater than 10 thousand than give that employe a salary increment of 15%, 20% if greater than 20 thousand, 25% abv to 30000/-

    He wrote

    void IncremetSalary(){

    if(salary > 10000){

    int  newSalary = (int)salary * 0.15;

    print("1500");

    }

    else if(salary > 20000){

    int  newSalary = (int)salary * 0.20;

    print("4000");

    }

    }

    i repeat him 4 times, but he always prints 1500 ... 4000 :-(



  • @SalikChughtai said:

    int  newSalary = (int)salary * 0.15;

    I sure wouldn't like that kind of an increment.



  • @SalikChughtai said:

    I asked a student to write a Function if Salary is greater than 10 thousand than give that employe a salary increment of 15%, 20% if greater than 20 thousand, 25% abv to 30000/-

    He wrote ..(snip)

     

    One line requirement will almost always give silly program to end user. You need to break down requirement and present test cases. Instead of repeat 4 times.

     

     



  • @Nagesh said:

    @SalikChughtai said:

    I asked a student to write a Function if Salary is greater than 10 thousand than give that employe a salary increment of 15%, 20% if greater than 20 thousand, 25% abv to 30000/-

    He wrote ..(snip)

     

    One line requirement will almost always give silly program to end user. You need to break down requirement and present test cases. Instead of repeat 4 times.

    Yeah, because clearly the problem here was the requirement..



  • @Maciejasjmj said:

    @SalikChughtai said:
    int  newSalary = (int)salary * 0.15;

    I sure wouldn't like that kind of an increment.

    Surely you mean incremet.

    To be fair (I do not assume) we don't see what he's doing with the newSalary variable-- maybe it gets summed with salary before being returned. EDIT: oh wait I just noticed it's scoped to the if() so nevermind.



  • Give the guy a break... he's a student.



    Just like blakey, he hasn't learned to do stuff properly yet!



  • PUBLIC FUNCTION INCREMENT_SALARY(CUR_SALARY AS DOUBLE) AS DOUBLE
    DIM NEW_SALARY AS DOUBLE
    DIM SAL_INCREMENT AS DOUBLE

    SELECT CASE CUR_SALARY

    CASE CUR_SALARY <= 10000
    SAL_INCREMENT = 0

    CASE ( CUR_SALARY > 10000 AND CUR_SALARY < 20000 )
    SAL_INCREMENT = .15

    CASE (CUR_SALARY >20000 AND CUR_SALARY < 30000
    SAL_INCREMENT = .20

    CASE ELSE
    SAL_INCREMENT = .25

    END CASE

    NEW_SALARY = CUR_SALARY + CUR_SALARY * SAL_INCREMENT

    RETURN NEW_SALARY

    END FUNCTION



  • @morbiuswilters said:

    @Nagesh said:

    @SalikChughtai said:

    I asked a student to write a Function if Salary is greater than 10 thousand than give that employe a salary increment of 15%, 20% if greater than 20 thousand, 25% abv to 30000/-

    He wrote ..(snip)

     

    One line requirement will almost always give silly program to end user. You need to break down requirement and present test cases. Instead of repeat 4 times.

    Yeah, because clearly the problem here was the requirement..

     

     

    Yes. obvious problem is obvious!

     



  • @Nagesh said:

    @morbiuswilters said:

    @Nagesh said:

    @SalikChughtai said:

    I asked a student to write a Function if Salary is greater than 10 thousand than give that employe a salary increment of 15%, 20% if greater than 20 thousand, 25% abv to 30000/-

    He wrote ..(snip)

     

    One line requirement will almost always give silly program to end user. You need to break down requirement and present test cases. Instead of repeat 4 times.

    Yeah, because clearly the problem here was the requirement..
     

     

    Yes. obvious problem is obvious!

     

    I figured out what he wanted from the single line requirements, and I am an idiot. 



  • @Medezark said:

    @Nagesh said:

    @morbiuswilters said:

    @Nagesh said:

    @SalikChughtai said:

    I asked a student to write a Function if Salary is greater than 10 thousand than give that employe a salary increment of 15%, 20% if greater than 20 thousand, 25% abv to 30000/-

    He wrote ..(snip)

     

    One line requirement will almost always give silly program to end user. You need to break down requirement and present test cases. Instead of repeat 4 times.

    Yeah, because clearly the problem here was the requirement..
     

     

    Yes. obvious problem is obvious!

     

    I figured out what he wanted from the single line requirements, and I am an idiot. 

     

     


    You think you figured out, by making certain assumptions. You don't know if that is the correct client requirement. Also you've many years of experience under your stomach.
    I am not expert on idiots, but human like to make assumption that is how we are able to grasp concepts around us.

     


     



  • @Nagesh said:

    @Medezark said:
    @Nagesh said:
    @morbiuswilters said:
    @Nagesh said:
    @SalikChughtai said:

    I asked a student to write a Function if Salary is greater than 10 thousand than give that employe a salary increment of 15%, 20% if greater than 20 thousand, 25% abv to 30000/-

    He wrote ..(snip)

     
    One line requirement will almost always give silly program to end user. You need to break down requirement and present test cases. Instead of repeat 4 times.
    Yeah, because clearly the problem here was the requirement..
     
    Yes. obvious problem is obvious!

    I figured out what he wanted from the single line requirements, and I am an idiot. 
     
    You think you figured out, by making certain assumptions. You don't know if that is the correct client requirement. Also you've many years of experience under your stomach.
    I am not expert on idiots, but human like to make assumption that is how we are able to grasp concepts around us.

    Upon further reflection, you are correct.  We all assume that our conceptualization of a problem and solution is going to be the same for any rational being.  Our first assumption that we ourselves are rational beings and our second that all others rationality is or should be equivalent.  While the majority of the persons on this forum would take the assignment and obtain the "correct" result, a few would go off on a (to the rest of us) bizarre tangent.  SSDS comes to mind.  It is billed by it's author as a "Desktop Search Engine" and in his rationalization that is what it is.  To others it is an overblown video player.



  • Hey, it's MedezarkSwamp!



  • @El_Heffe said:

    Hey, it's MedezarkSwamp!

    The shame won't come off with ajax.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.