Question

In: Computer Science

I am given this starter code and I am suppose to debug it and all of...

I am given this starter code and I am suppose to debug it and all of that and it will not work after I change ">" to "<=" and then i'm not sure after that what else I have to do. Could someone help me solve this?

// Start with a penny
// double it every day
// how much do you have in a 30-day month?
public class DebugSix1
{
   public static void main(String args[])
   {
      final int DAYS = 30;
      double money = 0.01;
      int day = 1;
      while(day > DAYS);
      {
         money = 2 * money;
         ++days;
         System.out.println("After day " + day +
            " you have " + moneyAmt);
      }
   }
}

That is the starter code. This is with the Java Programming 9th edition by Joyce Farrel and the other tutorials i have found do not show it with this starter code so I am confused.

Solutions

Expert Solution

// Start with a penny
// double it every day
// how much do you have in a 30-day month?
public class DebugSix1 {
    public static void main(String args[]) {
        final int DAYS = 30;
        double money = 0.01;
        int day = 1;
        while (day <= DAYS)
        {
            money = 2 * money;
            System.out.println("After day " + day + " you have " + money);
            ++day;
        }
    }
}



Related Solutions

please debug this code by fixing all the mistakes. thank you. // Creates a HomeworkAssignment class...
please debug this code by fixing all the mistakes. thank you. // Creates a HomeworkAssignment class // instantiates two objects // and prompts the user for infromation about two courses using System; public class DebugSeven1 {     public static void Main()     {         HomeworkAssignment course1;         HomeworkAssignment course2;         string entryString;         int exercises;         // Get info for first class         Console.Write("What class do you have homework for? ");         entryString = Console.ReadLine(); // Fixed .ReadLine         course1.ClassName...
Into to PythonInstructions: • In this lab you are to debug the code found at...
Into to PythonInstructions: • In this lab you are to debug the code found at the end of these instructions: Find and correct all problems found in the code. Create comments in the code explaining what you found and how you corrected it • The purpose of this program is to calculate car insurance rates using the following rules: The base rate of insurance is $50 a month, Males pay a 25% premium over the base rate, Drivers in Michigan...
Please fix this code I am having issues compiling it all together there is 3 codes...
Please fix this code I am having issues compiling it all together there is 3 codes here and it's giving me errors in my main method..... I feel like it might be something simple but I can't seem to find it. package assignement2; import java.util.ArrayList; import java.util.Scanner; public class reg1 { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter the number of items: "); int number = input.nextInt(); input.nextLine(); for (int i = 0; i <...
Hello, I am working on a C-program that deals with memory mapping, Please show all code...
Hello, I am working on a C-program that deals with memory mapping, Please show all code (code must be in the C) and outputs. The instructions are as follows INSTRUCTIONS: You have two sample c codes, one for the client and one for the server. IF the client makes a change in the shared memory, those changes will show on the server side. Your task is to adapt the change strategy to develop two applications so they can send messages...
Here is my fibonacci code using pthreads. When I run the code, I am asked for...
Here is my fibonacci code using pthreads. When I run the code, I am asked for a number; however, when I enter in a number, I get my error message of "invalid character." ALSO, if I enter "55" as a number, my code automatically terminates to 0. I copied my code below. PLEASE HELP WITH THE ERROR!!! #include #include #include #include #include int shared_data[10000]; void *fibonacci_thread(void* params); void parent(int* numbers); int main() {    int numbers = 0; //user input....
I am creating SAS code, but am receiving an errors " ERROR: Value is out of...
I am creating SAS code, but am receiving an errors " ERROR: Value is out of range or inappropriate. ERROR: No body file. HTML5(WEB) output will not be created." This is the code: option ls=65 ps=65; data one; input IQ; cards; 145 139 122 ; title 'Normal Quantile - Quantile Plot for IQ'; ods graphics on; proc univariate data=one; qqplot IQ / normal (mu=est sigma=est); run;
Assembly Question: I am trying to annotate this code and am struggling to understand what it...
Assembly Question: I am trying to annotate this code and am struggling to understand what it is doing. Can someone please add comments? .data .star: .string "*" .line: .string "\n" .input: .string "%d" .count: .space 8 .text .global main printstars: push %rsi push %rdi _printstars: push %rdi mov $.star, %rdi xor %rax, %rax call printf pop %rdi dec %rdi cmp $0, %rdi jg _printstars mov $.line, %rdi xor %rax, %rax call printf pop %rdi pop %rsi ret printstarpyramid: mov %rdi,...
I need the Java Code and Flowchart for the following program: Suppose you are given a...
I need the Java Code and Flowchart for the following program: Suppose you are given a 6-by-6 matrix filled with 0s and 1s. All rows and all columns have an even number of 1s. Let the user flip one cell (i.e., flip from 1 to 0 or from 0 to 1) and write a program to find which cell was flipped. Your program should prompt the user to enter a 6-by-6 array with 0s and 1s and find the first...
What information is needed? This is all the information I am given. Miscellaneous protozoa case study...
What information is needed? This is all the information I am given. Miscellaneous protozoa case study A 4-year-old boy from Talavera, Nueva Ecija complains of abdominal pain with low grade fever and vomiting. A routine ova and parasite examination were performed on stool specimen, but no intestinal parasite seen. Skeptical to the results, the doctor requested for another stool specimen for O&P. Second O&P shows an intestinal parasite measures 25μm in diameter with homogenously stained (trichrome stain) central body surrounded...
I am trying to start saving for retirement. I am investing all my cash into the...
I am trying to start saving for retirement. I am investing all my cash into the S&P 500, which will assume consistently 9.8% interest, compounded annually. I initially put a lump sum of $100 into my account, and I will deposit $10 every second week. a) After 10 years, how much money will I have invested? b) After 10 years, if I sold all of my stocks, how much money will I have in my account? c) After 25 years,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT