The current project asks you to evaluate the Sith population. The Sith populatio
ID: 3635163 • Letter: T
Question
The current project asks you to evaluate the Sith population. The Sith population grows at the aforementioned rate and has a time period of 5 days. Hence, if a Sith population starts out as 10 Siths, then in 5 days there are still 10 Siths; in 10 days, there are 20 Siths; in 15 days, 30 Siths; in 20 days, 50 Siths; and so forth. Write a program that takes both the initial size of the Sith population AND the number of days as input from the user. The program then outputs the population after that many days. assume that the population size is the same for 4 days and then increases every fifth day. Your program should allow the user to repeat this calculation as often as desired. (You will need to determine which loop will accomodate these requirements).
i have to do this using a for loop
Explanation / Answer
if i understand you right, the increase would be 10 sith per 5 days, with a gap of 5 days in the beginning, where no increase would take place. I assume you misspelled, when you wrote 50 after 20 days because this would break a regular algorithm except if your about to follow the row like it. You dont actually need a loop, the easiest solution would be to calculate it: int sith = 10; // user input int days=20; // user input days -= (days % 5); // assures you get the next lower 5er series number sith = days - 5 > 0 ? (days - 5) * 2 : sith; System.out.println("sith: " + sith);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.