Simple Algorithms for Mark Sheet and Employee Bonus Calculation

  • Thread starter jackson6612
  • Start date
  • Tags
    Algorithms
In summary: I think the word "seed" would be appropriate here. It's like starting with zero in addition or multiplication. You have to have a known starting point.In Step 2 of the algorithm on Page 1 it says "Take the mark sheet of NEXT student" and the same is said in Step 3 of the algorithm on Page 2 "Take the appraisal form of the NEXT employee". What is that "NEXT" student/employee is the first student/employee; I mean when the algorithm has just stated working there would be always a 'first' case it will work on and once it is done with it, then it will proceed to the next case.The counter variable is used to keep track of which student/employee is
  • #1
jackson6612
334
1
Hi

Please help me with the following queries. Please be specific and simple in your replies. Thanks a lot.

Page 1:
http://img15.imageshack.us/img15/6656/chp11page1.jpg

Page 2:
http://img248.imageshack.us/img248/202/chp11page2.jpg

On page 1 the author says "Is total mark sheets checked = 50" but in the next example on page 2 the author says "If total employees checked < 100". Isn't that "<100" thing really confusing? Is the algorithm suppose to stop once the value is greater than 100 which won't happen? If the author had assigned the first employee index 0, then it would be more apt to say "If total employees checked = 99".

Moreover, don't you think a vital step is missing from the algorithm on page 2 after Step 7 because there would be employees who wouldn't receive any bonus but need to included in the counter of total employees checked?

What is the need to initialize the counters to zero in Step 1 of both algorithms?

In Step 2 of the algorithm on Page 1 it says "Take the mark sheet of NEXT student" and the same is said in Step 3 of the algorithm on Page 2 "Take the appraisal form of the NEXT employee". What is that "NEXT" student/employee is the first student/employee; I mean when the algorithm has just stated working there would be always a 'first' case it will work on and once it is done with it, then it will proceed to the next case.

Please help me with the above questions. I seriously need your help! Thanks a lot.
 
Technology news on Phys.org
  • #2
jackson6612 said:
HiOn page 1 the author says "Is total mark sheets checked = 50" but in the next example on page 2 the author says "If total employees checked < 100". Isn't that "<100" thing really confusing? Is the algorithm suppose to stop once the value is greater than 100 which won't happen? If the author had assigned the first employee index 0, then it would be more apt to say "If total employees checked = 99".
There's different ways to do it. In the first, he says if it's NOT 50, loop back to a previous step. In the second, he says if it IS less than 100, then loop back to a previous step. Both slightly different ways of doing similar things. Sometimes one is clearer than the other. I wouldn't worry about it.

Note that, in the second example, the counter is incremented at the end of the processing. So the first employee is indeed 0. After that record is processed, the counter increments. Think about it. You're on the last employee. He's number 99 (starting at 0). So you've finished processing him. Now you increment the counter to 100. That number is not smaller than 100, so the loop exits. So it does in fact exit after the last employee. And despite starting at 0, the counter accurately reflects the number of employees processed (100).

jackson6612 said:
Moreover, don't you think a vital step is missing from the algorithm on page 2 after Step 7 because there would be employees who wouldn't receive any bonus but need to included in the counter of total employees checked?
It specifically says there are three grades: A, B and C. So everyone gets a bonus in this case. And every employee is counted, regardless. Of course, if it was possible for an employee to not get a bonus (being neither A, B or C), you would need logic such as "otherwise, Bonus = 0" between steps 7 and 8.
jackson6612 said:
What is the need to initialize the counters to zero in Step 1 of both algorithms?

Good question. The answer is that you can't assume a value for a variable until you assign it a value. It's likely to contain garbage until you initialize it. So a general rule of programming is to make sure you initialize all your variables to sane values.

jackson6612 said:
In Step 2 of the algorithm on Page 1 it says "Take the mark sheet of NEXT student" and the same is said in Step 3 of the algorithm on Page 2 "Take the appraisal form of the NEXT employee". What is that "NEXT" student/employee is the first student/employee; I mean when the algorithm has just stated working there would be always a 'first' case it will work on and once it is done with it, then it will proceed to the next case.
Well, if you haven't started, you can consider the next one as the first one. Nothing wrong with that logic.
 
Last edited:
  • #3
jackson6612 said:
Hi

Please help me with the following queries. Please be specific and simple in your replies. Thanks a lot.

Page 1:
http://img15.imageshack.us/img15/6656/chp11page1.jpg

Page 2:
http://img248.imageshack.us/img248/202/chp11page2.jpg

On page 1 the author says "Is total mark sheets checked = 50" but in the next example on page 2 the author says "If total employees checked < 100". Isn't that "<100" thing really confusing?
The author doesn't seem to be very consistent.
jackson6612 said:
Is the algorithm suppose to stop once the value is greater than 100 which won't happen? If the author had assigned the first employee index 0, then it would be more apt to say "If total employees checked = 99".
Neither of these algorithms is very useful. Both are completely missing the step that returns to a previous step in a loop that is executed a specific number of times. The whole purpose of using a counter variable is to control the number of times a specific block of code (or steps in an algorithm) is executed.
jackson6612 said:
Moreover, don't you think a vital step is missing from the algorithm on page 2 after Step 7 because there would be employees who wouldn't receive any bonus but need to included in the counter of total employees checked?
The description preceding the algorithm implies that all employees get a bonus, since all of them would be in one of three categories.
jackson6612 said:
What is the need to initialize the counters to zero in Step 1 of both algorithms?
A counter variable that is incremented (added to) always has to start with some known number, typically zero.
jackson6612 said:
In Step 2 of the algorithm on Page 1 it says "Take the mark sheet of NEXT student" and the same is said in Step 3 of the algorithm on Page 2 "Take the appraisal form of the NEXT employee". What is that "NEXT" student/employee is the first student/employee; I mean when the algorithm has just stated working there would be always a 'first' case it will work on and once it is done with it, then it will proceed to the next case.
At the beginning of the process, the NEXT student or employee will be the first one.
jackson6612 said:
Please help me with the above questions. I seriously need your help! Thanks a lot.
 
  • #4
Mark44 said:
Neither of these algorithms is very useful. Both are completely missing the step that returns to a previous step in a loop that is executed a specific number of times. The whole purpose of using a counter variable is to control the number of times a specific block of code (or steps in an algorithm) is executed.
Might be me, but I'm not sure what you mean by that. In example 2:

Step 10: If Total_Employees_Checked < 100 Then go to Step 2.

The counter is correctly incremented, and it loops back to an appropriate place. When it's done 100 employees, it falls through to Step 11. Seems to me it will loop properly, but maybe I'm missing something.
 
  • #5
Grep said:
There's different ways to do it. In the first, he says if it's NOT 50, loop back to a previous step. In the second, he says if it IS less than 100, then loop back to a previous step. Both slightly different ways of doing similar things. Sometimes one is clearer than the other. I wouldn't worry about it.

Note that, in the second example, the counter is incremented at the end of the processing. So the first employee is indeed 0. After that record is processed, the counter increments. Think about it. You're on the last employee. He's number 99 (starting at 0). So you've finished processing him. Now you increment the counter to 100. That number is not smaller than 100, so the loop exits. So it does in fact exit after the last employee. And despite starting at 0, the counter accurately reflects the number of employees processed (100).

Thank you very much, Grep, Mark. You people are so nice. I wish you all prosperity and best wishes.

Please be concise, simple and straightforward in your replies because I know very little.

Grep, I don't get the bold part. Rather I would like to say I think there is something wrong with it. If the first employee was assigned value 0, then the last one would be assigned 99; and 99 is less than 100, i.e. 99<100. That would mean the the procedure would step back to Step 2 again which I think it should because it has already counted 100 employees (from 0-99). I would say the author is suggesting that the counter assigned the value of 1 to the first employee. Once it has processed the the last employee, the counter would be 100 and this is obviously not less than 100, i.e. 100 is not less 100 rather they are both equal.

Do I make any sense? Please let me know as soon as possible. Thanks a lot.
 
  • #6
Grep said:
Might be me, but I'm not sure what you mean by that. In example 2:

Step 10: If Total_Employees_Checked < 100 Then go to Step 2.

The counter is correctly incremented, and it loops back to an appropriate place. When it's done 100 employees, it falls through to Step 11. Seems to me it will loop properly, but maybe I'm missing something.
Nope, my mistake. I don't know how I missed this in both algorithms.
 
  • #7
jackson6612 said:
Thank you very much, Grep, Mark. You people are so nice. I wish you all prosperity and best wishes.

Please be concise, simple and straightforward in your replies because I know very little.

Grep, I don't get the bold part. Rather I would like to say I think there is something wrong with it. If the first employee was assigned value 0, then the last one would be assigned 99; and 99 is less than 100, i.e. 99<100. That would mean the the procedure would step back to Step 2 again which I think it should because it has already counted 100 employees (from 0-99). I would say the author is suggesting that the counter assigned the value of 1 to the first employee. Once it has processed the the last employee, the counter would be 100 and this is obviously not less than 100, i.e. 100 is not less 100 rather they are both equal.

Nope. Go through the logic step by step. While processing the last employee, the counter is indeed 99 (and we're on the 100th employee). It is then incremented before the check is made and after the employee is processed. So after processing the last employee, the counter goes up to 100. Now, we loop back to Step 2 if the counter is less than 100. It's not, it's equal to 100 now. So it doesn't loop back. Rather, it goes on to Step 11.

And thanks for the kind words. :)
 
  • #8
Mark44 said:
Nope, my mistake. I don't know how I missed this in both algorithms.
hehe It happens to us all. Which is why I so often add disclaimers like "... but maybe I'm missing something" and so on.
 
  • #10
Grep, I think I get it now. I was interpreting in a wrong way. And those kind words! I wish I could offer you wonderful people something more than them, perhaps a gift and a thank you card! :-)

Mark, thanks a lot. You have really helped me with many of my problems.
 

Related to Simple Algorithms for Mark Sheet and Employee Bonus Calculation

What are simple algorithms?

Simple algorithms are a set of instructions or steps that are followed to solve a problem or complete a task. They are designed to be easy to understand and implement, making them suitable for a wide range of applications.

How can simple algorithms be used for mark sheet calculation?

Simple algorithms can be used to calculate marks for exams or assignments by assigning numerical values to grades and adding them up. For example, an A grade can be assigned a value of 5, a B grade a value of 4, and so on. The total marks can then be calculated by adding up these values.

How do simple algorithms help in employee bonus calculation?

Simple algorithms can be used to calculate employee bonuses by considering factors such as performance, years of service, and company profits. These factors can be assigned numerical values and then added together to determine the bonus amount for each employee.

What are the advantages of using simple algorithms for mark sheet and employee bonus calculation?

Some advantages of using simple algorithms for mark sheet and employee bonus calculation include their simplicity, efficiency, and accuracy. They also allow for easy customization and can be easily modified to suit different scenarios.

Are there any limitations to using simple algorithms for mark sheet and employee bonus calculation?

While simple algorithms are useful for basic calculations, they may not be suitable for complex scenarios. They also rely on the accuracy of input data, so any errors in data entry can affect the final results. Additionally, they may not take into account other factors that may affect marks or bonuses, such as personal circumstances or external influences.

Similar threads

  • Programming and Computer Science
Replies
4
Views
2K
  • Programming and Computer Science
Replies
1
Views
3K
  • Biology and Chemistry Homework Help
Replies
4
Views
2K
  • Programming and Computer Science
Replies
4
Views
3K
  • General Discussion
Replies
16
Views
2K
Replies
4
Views
4K
  • Introductory Physics Homework Help
Replies
9
Views
1K
  • Math Proof Training and Practice
2
Replies
67
Views
11K
Replies
35
Views
5K
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
2K
Back
Top