Question: / / Start with a penny / / double it every day / / how much do you have in x number of days? import

// Start with a penny
// double it every day
// how much do you have in x number of days?
import java.util.Scanner;
public class DebugSix1
{
public static void main(String args[])
{
Scanner keyboard = new Scanner(System.in);
int days;
double money =0.01;
int day =1;
System.out.print("Enter number of days >>")
days = keyboard.nextInt();
while(days < day)
{
money =2* money;
++day;
System.out.println("After day "+ days +
" you have "+ money);
}
}
}
The files provided in the code editor contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly.
An example of the program is shown below:
Enter number of days >>15
After day 2 you have 0.02
After day 3 you have 0.04
After day 4 you have 0.08
After day 5 you have 0.16
After day 6 you have 0.32
After day 7 you have 0.64
After day 8 you have 1.28
After day 9 you have 2.56
After day 10 you have 5.12
After day 11 you have 10.24
After day 12 you have 20.48
After day 13 you have 40.96
After day 14 you have 81.92
After day 15 you have 163.84
java

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!