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
Follow me on Tik-Tok​
ivanzaharov [21]

Answer:

Sure

Explanation:

5 0
3 years ago
Read 2 more answers
What do you use to add a new slide to your presentation.
gtnhenbr [62]

Answer:

you have to go to slides and it will say add slide and you click there and you have a slide.

Explanation:

4 0
2 years ago
What does obsolete mean?
Alex
No longer produced or used; out of date.
8 0
3 years ago
Read 2 more answers
What is a navigation bar?
jasenka [17]
A navigation bar (or navigation system) is a section of a graphical user interface intended to aid visitors in accessing information. Navigation bars are implemented in file browsers, web browsers and as a design element of some web sites.
6 0
3 years ago
What are 3 examples of Chassis Wiring?
Roman55 [17]

Answer:

.

Explanation:

5 0
3 years ago
Other questions:
  • The North American Free Trade Agreement (NAFTA) among Canada, Mexico, and the United States is intended to _____.
    5·2 answers
  • What is the difference between a rendering engine and a browser engine?
    5·2 answers
  • __ is/are the amount of blank space between lines of text in a paragraph
    7·2 answers
  • Select the term below which is a protocol that provides a method for software components to communicate, interact, and share dat
    6·1 answer
  • A(n) _____ measures the ability to juggle a variety of demands, as in a manager's job where the candidate is presented with simu
    8·1 answer
  • Five examples of technology in community​
    7·2 answers
  • so i just went to play forge of empires and when i logged on to it all of my progress was gone and i was so far in to it
    15·2 answers
  • Can you please help me with the AP Computer Science Fill in the blank. What goes on number 5 8 and 18. I don’t understand this I
    8·1 answer
  • Why I/O modules is needed between system bus<br>and I/O devices?​
    15·1 answer
  • Write in language C, please.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!