Help with salary calculations
Posted on 2004-10-30
I am currently in a java class and am looking for some help on a program that is due soon. It is called Pennies for Pay and wants the user to input a # of days worked between 1 and 40. The salary starts at $.01 for day 1 and doubles for every day worked. What I have done, is wrote my program with 40 if then statements which requires no calculation at all just an input that corresponds with an output. This has made my code very long. Other people in the class say their code is only 11 lines long and includes simple equations such as salary=pay+salary and pay=pay*2. The problem is that I am confused as to how to do the calculation without 40 if then statements. I have the rest of the program done and I already have a full program as stated before, I just would rather turn in it with a calculation and less code. Any help would be urgently appreciated. I am not looking for the answers or someone to do it for me, just a head in the right direction on this smal portion. Thank you in advance.