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.

Regards

Sudhakar

public class Penies {

public static void main(String[] args) {

int days = 0;

System.out.println("This program will calculate your salary for a number of days");

System.out.println("betwee

System.out.println("and doubling for every day worked.");

System.out.println("\nPlea

days = SavitchIn.readLineInt();

if ((days > 40) && (days < 0));

System.out.println("You have entered an invalid number of days.");

print(days,0.01) ;

}

public static void print(int days, double value) {

System.out.println("You worked "+days +" days. \nYour pay on day "+days+" is $"+value*Math.pow(2,days-1

double total=total(days,value);

System.out.println("Your total salary is "+total);

}

public static double total(int days,double value) {

if(days==0)

return 0;

double total=value*Math.pow(2,day

return total;

}

}