1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
sdas [7]
3 years ago
6

Suppose you find a magic $1.00 coin. Its magic power is as follows: as each day passes, you get an additional dollar plus half o

f what you already had (it appears by the window somehow).
Write a method called getRichQuick (no input is necessary for this method) that prints the first n days while your total is less than $1,000,000 dollars. In other words, how many days does it take for you to earn $1,000,000?
Your program should calculate these numbers and print the following output:
Day 1: $1
Day 2: $1 + ($1 + .50) = $2.50
Day 3: $2.50 + ($1 + 1.25) = $4.75
...
Day N: $X + ($1 + Y) ≥ $1000000
Computers and Technology
1 answer:
AfilCa [17]3 years ago
7 0

Answer:

See explaination

Explanation:

public class QuickRich {

static void getRichQuick() {

double amount = 1;

int day = 1;

System.out.println("Day 1: $1");

while (amount < 1000000) {

day++;

if(amount + 1 + (amount/2) < 1000000)

System.out.printf("Day %d: $%.2f + ($1 + %.2f) = $%.2f\n", day, amount, amount/2, amount+(amount/2)+1);

else

System.out.printf("Day %d: $%.2f + ($1 + %.2f) >= $1000000\n", day, amount, amount/2);

amount += (1 + (amount/2));

}

}

public static void main(String[] args) {

getRichQuick();

}

}

You might be interested in
Jonathan is in the process of creating a photo of a fluttering flag with cars moving around in the background. He wants the flag
Dominik [7]

Answer:

Explanation:

In order to achieve the desired result, Jonathan should first apply a motion blur effect to the picture. This will cause the moving background objects to become blurred, out of focus, and appear as streaks of light since they are moving at a very fast speed. Next, Jonathan should apply an enhanced focus filter to the flag so that it stands out from the blurred background. These two effects/filters should let Jonathan achieve his desired result.

7 0
3 years ago
Read 2 more answers
What are some objects in your home that demonstrate electrical energy to radiant energy to thermal energy
Bogdan [553]
Definitely a lamp or a stove
6 0
3 years ago
Read 2 more answers
Create a recursive method, a method that calls itself, that returns the number of vowels that appear in any string given. Keep i
kvv77 [185]
<h2>Answer:</h2>

//Define the method as noOfVowels

   //Let it receive the string to be checked as argument

   public static int noOfVowels(String string){

   

       //Check the length of the string

       

       //If it is less than 1, then it is an empty string

       //Hence return 0

       if(string.length() < 1){    

           return 0;

       }

       

       //Else,

       else{

           //get the character at the first position in the string

           //and convert it to a lower case

           char x = string.toLowerCase().charAt(0);

           //Check if the character is a vowel

           if (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u'){

               //if it is a vowel, add 1 to a recall of the method.

               //But this time, call the method with  

               //the string excluding the first character.

               //i.e the substring of the string starting at index 1 rather than 0

               return 1 + noOfVowels(string.substring(1));

           }

           

           else {

               //If it is not a vowel, just recall the method with

               //the string excluding the first character

               //i.e the substring of the string starting at index 1 rather than 0

               return noOfVowels(string.substring(1));

           }

       }

   }

   

<h2>Explanation:</h2><h2></h2>

The code has been written in Java and it contains comments explaining every part of the code. Please go through the comments carefully.

The actual lines of code have been written in bold face to distinguish them from comments.

The code is re-written without comments as follows;

   public static int noOfVowels(String string){

   

       if(string.length() < 1){    

           return 0;

       }

       

       else{

           char x = string.toLowerCase().charAt(0);

           if (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u'){

               return 1 + noOfVowels(string.substring(1));

           }

           

           else{

               return noOfVowels(string.substring(1));

           }

       }

   }

   

3 0
3 years ago
A user can set the security and privacy settings on what is displayed in the message bar from the ________ within the options me
djverab [1.8K]
Depends on the Operating System
6 0
3 years ago
What kind of software consists of programs designed to make users more productive and/or assist them with personal tasks?
Sunny_sXe [5.5K]
It is application software
6 0
2 years ago
Other questions:
  • What operator is used to create a validation rule? A. – B. / C. &lt; or &gt; D. +
    12·1 answer
  • Your mobile device files can be synchronized using ________. hdmi a secure digital transmission a display adapter a cloud servic
    11·1 answer
  • Which of the following is a full selector?
    12·1 answer
  • A _____ captures the pattern in a _____ and sends it to the computer, where special software translates the _____ into meaningfu
    8·1 answer
  • Whats the difference between search engine and web browser?
    6·2 answers
  • Write the definition of a class Clock. The class has no constructors and three instance variables. One is of type int called hou
    12·1 answer
  • Is a router on the local network that is used to deliver packets to a remote network?
    15·1 answer
  • Which paragraph from the article helps explain what “engaged” is referring to?
    9·1 answer
  • Anybody know this question??
    8·1 answer
  • What is the difference between mutex lock and race condition​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!