- #1
remaan
- 132
- 0
Homework Statement
In this problem, we are asked to write a program which displays the salary of a person for one month. Given that his salary for the first day is 1, second day 2 $ , third day 4$ , and contiue to double . And, then we have to display the total salary of the whole month.
The Attempt at a Solution
Her is the code I made
public class Ass3 {
public static void main (String args [])
{
int salary = 1;
System.out.println(salary);
for ( int d = 0 ; d < 29 ; d++)
{
salary *=2;
System.out.println(salary);
}
}
}
I tired with making total = 0 and then total = total + salary,
But it did Not work, even when putting inside the loop itself ?
What do you think ?