- Jan 7, 2002
- 9,448
- 1
- 76
I was asked to do a trace table and tell if the algorithm was valid or not, and the instructor never really said what would make it invalid.
I did the trace table, came up with the numbers, then I actually copied the program from the books example to check my results. they were the same, but I don't know if they are VALID. (This is from week 1 class)
Program: for calculating an employees wages for the week.
Input: employeeId, payRate, hoursWorked
Output: pay
Very simple. but the identifiers are floats, and no rounding off has been added or set width, so the output is a raw float.
My Questions:
a)No pause at the end, you never see the pay.
b)Numbers, because they are floats, drop trailing zeros, so 500.50 becomes 500.5.
c)Same situation but it carried the number to three places 500.875.
It never said you would SEE the pay, it would just calculate it, so I think that if fine.
I don't think those are valid outputs for this type of program, even though we didn't cover integers and floats until last week. Am I wrong in assuming this?
TIA
P.S. The main part of the exercise was writing the trace tables, but I have "sleepy" notes and it's scribbled "are these valid algorithms" near the bottom.
It's a five hour class with three straight hours of lecture, two in the lab, ending at 10PM, and I am taking 22 units. So, I was a bit tired when he wrote this on the board at the end of lab and not even sure if they go with this program.
I did the trace table, came up with the numbers, then I actually copied the program from the books example to check my results. they were the same, but I don't know if they are VALID. (This is from week 1 class)
Program: for calculating an employees wages for the week.
Input: employeeId, payRate, hoursWorked
Output: pay
Very simple. but the identifiers are floats, and no rounding off has been added or set width, so the output is a raw float.
My Questions:
a)No pause at the end, you never see the pay.
b)Numbers, because they are floats, drop trailing zeros, so 500.50 becomes 500.5.
c)Same situation but it carried the number to three places 500.875.
It never said you would SEE the pay, it would just calculate it, so I think that if fine.
I don't think those are valid outputs for this type of program, even though we didn't cover integers and floats until last week. Am I wrong in assuming this?
TIA
P.S. The main part of the exercise was writing the trace tables, but I have "sleepy" notes and it's scribbled "are these valid algorithms" near the bottom.
It's a five hour class with three straight hours of lecture, two in the lab, ending at 10PM, and I am taking 22 units. So, I was a bit tired when he wrote this on the board at the end of lab and not even sure if they go with this program.
