Liberty Basic Payroll Calculator IF ELSE -
i'm getting started learning basic programming sams , having issues simple payroll calculator i've been trying write. explain how better rewrite this? , can follow if statements print command? think i'll have invest in newer book hoping run @ least in meantime.
input "please input payrate: "; ans$ print input "please input hours worked: "; hrs$ if (hrs$ >= "40") payrate = (hrs$ * ans$) else if (hrs$ <= "41") payrate = hrs$ * (1.5 * ans$) end if taxrate = payrate * .15 grosspay = payrate * hrs$ netpay = payrate - taxrate print print: "your net pay is: "; netpay
i don't use liberty, imagine it's complaining when you're trying math on strings. additionally, find misuse of "payrate" name confusing. logic of overtime calc wrong. here's first attempt @ rewrite:
input "please input payrate: "; rate$ rate = val(rate$) print input "please input hours worked: "; hrs$ hrs = val(hrs$) gross = hrs * rate if hrs > 40 gross = gross + ((hrs - 40) * rate / 2)) taxes = gross * .15 net = gross - taxes print print: "your gross pay is: "; gross print: "your net pay (after $";taxes;" in taxes) is: "; net
Comments
Post a Comment