Posts: 14
Threads: 1
Joined: May 2004
I am enrolled in a SC401 class and my final assignment is to write a program that takes employees names, hours worked and pay rate, and calculates the overtime then print the information with the pay for each emp and then show total paid for all three emp. (I am not asking for someone to do this, just some help
) I have got it to show the emp, hr and gross pay for each emp, including overtime, and I also have a "total pay is $###.##" but its reading the information for the last loop before the terminator ...ie totalpay=pay + pay + pay ( my first "gross pay" was 250.00, my secnd was 312.00, third 260.00 but its shows 780.00 as total pay which is 260.00 * 3) Any pointers or where I may find examples to view would be wonderful.
Don
assman exits stage left
Posts: 2,765
Threads: 138
Joined: Nov 2002
totalpay=pay + pay + pay?
assuming that your are using the same variable for each pay and the it is last set to 260.... it does exactly what you told it to do
use different variables... or maybe *gasp* arrays
edit: also some code would be nice
edit2: welcome to the forums :king:
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 14
Threads: 1
Joined: May 2004
Thank you,
my prog reads the data then calculated the pay * hours and the overtime pay * hours, if any, then prints the empl infor.
(employeename, hours##, grosspay$###.##)
once it reads the termintor in my data it goto total pay line
I have tryed array, at least thats what I think it is
for i=0 to 2
next i
but it did nothing. am I head the right direction?
I can post my code tonight when I get home.
Thanks again
assman exits stage left
Posts: 2,765
Threads: 138
Joined: Nov 2002
thats becauase thats not an array. thats a FOR NEXT loop
an array is an arrangement of memory elements in one or more planes.
or in other words a bunch of boxes stacked like this
Code:
|_|_|_|_|_|
|_|_|_|_|_|
|_|_|_|_|_|
|_|_|_|_|_|
|_|_|_|_|_|
space 3,3 is
Code:
|_|_|_|_|_|
|_|_|_|_|_|
|_|_|*|_|_|
|_|_|_|_|_|
|_|_|_|_|_|
ok to dimension an array you
DIM array (x,y)
x and y can be any number
oh yea also you can also have only one row
DIM array(x)
Code:
DIM emppay(3)
emppay(1) = 250.00
emppay(2) = 312.00
emppay(3) = 260.00
FOR i = 1 TO 3
totalpay = emppay(i) + totalpay
NEXT i
PRINT totalpay
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 14
Threads: 1
Joined: May 2004
Oh, OK, I was wrong. I will read some more on arrays
thanks for the information
Should I post my code?
assman exits stage left
Posts: 684
Threads: 64
Joined: May 2004
Ooh Ooh! Can I try!
I hope this is what you are looking for. (And correct me for any mistakes) Can you have code before arrays? Oh, and where do you put TYPE statments?
Code:
TYPE employee
name$
wage!
hours!
INPUT "How many employees do you want to record?", numemp%
DIM emppay(numemp%)
DIM employee(numemp%) AS employee
FOR i=1 to numemp%
PRINT "Employee name:"
INPUT , employee.name$(i)
PRINT "Emplyee wage per hour:"
INPUT , employee.wage!(i)
PRINT "Enployee's hours worked:"
INPUT , employee.hours!(i)
emppay(i) = employee.wage!(i) * employee.hours!(i)
next i
`Now, print it nicely
format$ = "/ / $$##.##/ ## / $$#,###.##"
PRINT Employee Name Wage Hours Total Pay
PRINT --------------------- -------- -------- ------------------
FOR i = 1 to numemp%
PRINT USING , format$ ; employee.name$(i); employee.wage!(i); employee.hours!(i); emppay!(i)
next i
Did I do that right? Well, until you get confirmation, don't get any ideas.[/code]
quote="Deleter"]judging gameplay, you can adaquately compare quake 4 with pong[/quote]
Posts: 2,765
Threads: 138
Joined: Nov 2002
youd did the TYPE wrong but beside that (and with a little modifacation) it would do exactly what Don wants it to do
but Torahteen don't post the whole completed thing. let him do some work =P
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 14
Threads: 1
Joined: May 2004
well, mine is not so nice. Actualy I am more of a newbie than maybe this forum is for. I have been reading alot but need to see it to understand. I will get it! Just lookin for some assistance in finding my answer.
Thanks
Don
assman exits stage left
Posts: 2,765
Threads: 138
Joined: Nov 2002
Quote:well, mine is not so nice. Actualy I am more of a newbie than maybe this forum is for. I have been reading alot but need to see it to understand. I will get it! Just lookin for some assistance in finding my answer.
Thanks
Don
hehe nobodies code is perfect. and actually you havn't seen any of the complete newbies here. keep going at it.
*yawn* tommorow i will return!
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 14
Threads: 1
Joined: May 2004
This is how I wrote may program: (don't laugh) hehehe
REM Program to calcuate Employees hours and pay
CLS
0 PRINT " NAME ", "HOURS ", "PAY"
5 PRINT
6 rem employees name, hours worked, pay rate
10 DATA Alley Oop, 40, 6.25
20 DATA Jack Daniels, 48, 6
30 DATA Johnny Walker, 40, 6.50
40 DATA last one, 0, 0
41 rem E$=employee name hr=hours worked pay=payrate
45 READ e$, hr, pay
49 IF pay = 0 THEN GOTO 180
50 REM ot=overtime pay, othr=overtime hours
51 ot = pay * 1.5
52 othr = hr - 40
53 REM grpay=gross pay
55 IF hr > 40 THEN grpay = 40 * pay + othr * ot
65 IF hr < 41 THEN grpay = hr * pay
100 PRINT USING "& ## $###.##"; e$; hr; grpay
101 rem topay= total pay
110 topay = grpay + grpay + grpay
170 GOTO 45
180 PRINT
190 PRINT USING "Total pay is $###.##"; topay
200 END
Pretty basic, its all have have learned so far. I just can't get the print format to work for the data, and I can't get the correct sum of all the gross pays.
assman exits stage left