I need to write a program in Java for this problem : \"write a program that calc
ID: 3650428 • Letter: I
Question
I need to write a program in Java for this problem : "write a program that calculates the amount a person would earn over a period of time if his or her salary is one penny the first day, two pennies the second day, and continues to double each day. the program should display a table showing the salary for each day, and then show the total pay at the end of the period. the output should be displayed in a dollar amount, not the number of pennies"It needs to be set up in a table that shows day amount and total for each day.
ANy help would be great.
Thank you
Explanation / Answer
This is the exact working code.Checked in eclipse and is working fine.
Please rate the best answer first.
------------------------------------------------------------
import java.util.Scanner;
public class Salary {
public static Scanner scan=new Scanner(System.in);
public static void main(String[] args)
{
int days;
int j=1,i=0;
double total;
System.out.println("enter the number of days");
days=scan.nextInt();
for( i=0,j=1;i<days;i++,j*=2)
{
System.out.println("day "+(i+1)+" :"+j);
}
total=(double)j/100;
System.out.println("total earning : "+total+"$");
}
}