473,324 Members | 2,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Stuck on Population Growth Homework

Hello, my homework for computer class says

"• In a biology experiment, Cory finds that a sample of
microorganisms doubles in population every 12 hours. He
wants to know how many hours it will take to reach a
certain microorganism population level if he starts with
1000 organisms each time.
• WAM (write a method) to receive an integer N representing a desired
organism population level, and determine how many
hours it will be until the population level reaches N or
more organisms."

I can't seem to figure this out at all, the code I have so far reads as follows:

public static int (int X, int Y) {
int size = X;
int hours = 0;
while (size<=Y) {
size * 2;
}
}
Feb 7 '20 #1
1 1998
dev7060
633 Expert 512MB
..to receive an integer N..
The function has to accept only one formal argument.

Expand|Select|Wrap|Line Numbers
  1. public static int (int X, int Y) {
No function name is mentioned.

Expand|Select|Wrap|Line Numbers
  1. while (size<=Y) 
It should not check for equality here. Refer the question:
...level reaches N or more organisms...

Expand|Select|Wrap|Line Numbers
  1. size * 2;
This surely is doing size*2 but isn't updating any value.

See the required changes below:
Expand|Select|Wrap|Line Numbers
  1. public static int fun (int N) {
  2.   int size=1000;
  3.   int hours = 0;
  4.   while (size<N) {
  5.     hours+=12;
  6.     size*=2;
  7.   }
  8.   return hours;
  9. }
  10.  
Feb 7 '20 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: | last post by:
I have this question for homework in an intro perl class, I was hoping for some quick help on this please...here is the question Using the Perl programming language, please prepare the following...
2
by: Bilal | last post by:
Hello, I'm stuck on this problem for quite some time and hope somebody would be able to guide me. Basically, I need to populate a large number of "template" XML files which have all...
3
by: jumpskirt9 | last post by:
Hi all, I'm having problem with this assignment. I just started C++ and I just can't get this assignment...if anyone could help me out and give me a code...it would be greatly appreciated. The...
14
by: neonman14 | last post by:
Hello I am in Intro to Java Programming and I am having problems with assignment. The Homework assignment is called Population. Population Write a program that will predict the size of a...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.