Some help with a simple program... Calculating overtime pay... - Printable Version +- Qbasicnews.com (http://qbasicnews.com/newforum) +-- Forum: QBasic (http://qbasicnews.com/newforum/forum-4.html) +--- Forum: QB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-11.html) +--- Thread: Some help with a simple program... Calculating overtime pay... (/thread-10119.html) |
Some help with a simple program... Calculating overtime pay... - Temperence - 05-11-2008 Trying to write a simple script to calculate overtime pay for four individuals. Overtime starts after 40 hours, and is 1.5 normal wage. It's telling me "Type mismatch error on line 4." Quote:DATA Alley Oop, 40, 6.25, Jack Daniels, 48, 6, Johnny Walker, 40, 6.50, Last One, 0, 0 Re: Some help with a simple program... Calculating overtime pay... - Ralph - 05-11-2008 I found two problems: 1. The variables U must be strings, so, they must be used as U1$, U2$, U3$, and U4$ throughout 2. You must include the case where the hours worked are NOT larger then 40. I did it by changing your code thus, where I show the change for the first values: IF H1 > 40 THEN  LET T1 = P1 * 40  T1 = T1 + P1 * 1.5 * (H1 - 40) 'the other parenthesis are not required ELSE  T1 = P1 * H1 END IF Just change the following three cases accordingly. Re: Some help with a simple program... Calculating overtime pay... - Temperence - 05-11-2008 Thanks Ralph! Re: Some help with a simple program... Calculating overtime pay... - Ralph - 05-11-2008 Happy to have been of some help!  Keep using QB for other things. It's always a nice challenge. Re: Some help with a simple program... Calculating overtime pay... - Ralph - 05-12-2008 By the way, I would have coded your program using arrays, such as: U1$(4), H1(4), P1(4) Then, to read, you could use: FOR i = 1 to 4  READ U1$(i), H1(i),P1(i) NEXT i That would read all the values into the variables. I would code the following parts in a similar manner. |