Re: Tutorial of sorts

new topic     » goto parent     » topic index » view thread      » older message » newer message

Here's another try

--Euphoria code starts
--This is a version of PAY.ex
sequence cmd, name, temp, titleline
atom taxrate, hours, payrate, takehome, gross, tax
titleline={"Name","Hours worked","Gross pay","Tax","Net pay"}
include get.e

cmd=command_line()

if length(cmd) !=5 then printf(1, "Data entry error at command
line",{}) abort(0) end if

name=cmd[3]
temp=value(cmd[4])
    if temp[1]=GET_SUCCESS then hours=temp[2]
        else printf(1, "Data error in hours",{}) abort(0) end if

temp=value(cmd[5])
    if temp[1]=GET_SUCCESS then payrate=temp[2]
        else printf(1, "Data error in rate",{}) abort(0) end if

taxrate=0.25

gross=hours*payrate
tax=gross*taxrate
takehome=gross-tax

printf(1, "%9s %12s %12s %12s %12s\n", titleline)
printf(1, "%9s %12d %12.2f %12.2f %12.2f", {name, hours, gross, tax,
takehome})

--Euphoria code ends

Bye
Martin

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu