473,396 Members | 1,987 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,396 software developers and data experts.

Population and Class

Hi,

I have an assignment that is somewhat similar to the last guys:

Write a class that will predict the size of a population of organisms. The class should store the starting # of ogranisms, their average daily population increase(as a percentage), and the number of days they will multiply. The class should have amethod that uses a loop to display the size of the population for each day.
Test the class in a program that asks the user for the starting size of teh pop., thier avg daily increase, the # of days they will multiply. The program should display the daily pop.

Input validation: do not accept a number < 2 for the starting size of the pop. do not accept a negative number for avg daily pop increase. Do not accept a # less than one for the # of days they will multiply.
May 4 '07 #1
3 2877
Hi,

I have an assignment that is somewhat similar to the last guys:

Write a class that will predict the size of a population of organisms. The class should store the starting # of ogranisms, their average daily population increase(as a percentage), and the number of days they will multiply. The class should have amethod that uses a loop to display the size of the population for each day.
Test the class in a program that asks the user for the starting size of teh pop., thier avg daily increase, the # of days they will multiply. The program should display the daily pop.

Input validation: do not accept a number < 2 for the starting size of the pop. do not accept a negative number for avg daily pop increase. Do not accept a # less than one for the # of days they will multiply.

This is what i have thus far
import java.util.Scanner;

public class Population1
{

public static void main(String[] a)
{
int startPop; //store the population
int avgIncrease; //store the average daily population
int days; //store the number of days they will multiply
String input; //Store data from keyboard
char YN; //Holds data for yes or no
int total;

//Create Scanner object to for keybrd input
Scanner kb = new Scanner(System.in);
Population P = new Population();

do{

//Get the number of organisms
System.out.print("\nEnter the number of organisms: ");
startPop = kb.nextInt();

//Get the number for daily increase
System.out.print("Enter a number for the average daily growth: ");
avgIncrease = kb.nextInt();
avgIncrease = avgIncrease / 100;

//Get the number of days for multiplying
System.out.print("Enter # of days for multiplying: ");
days = kb.nextInt();




}
while(startPop >= 2 || avgIncrease > 0 || days >=1);
{

//Does the user want to re-enter data?

System.out.println("Note:\n(1)Enter ONLY positive numbers.\n" +"(2)Initial"
+ " populaton must be greater than 2. \n" + "(3)"
+ "Number of days must be greater than 1.");
System.out.println("Would you like to enter numbers again? ");
System.out.print("Enter Y for yes or N for no: ");
input = kb.next();
YN = input.charAt(0);

}

}



}
May 4 '07 #2
Ganon11
3,652 Expert 2GB
And what are you having trouble with?

(Please use the [code] tags when posting your code. Just click and drag over your code and hit the # symbol in your Reply box).
May 4 '07 #3
I'm not certain of creating a method that uses a loop to display the size of the population for each day.
May 5 '07 #4

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

Similar topics

1
by: Eric O. Angell | last post by:
Say I have class Header: def __init__(self): self.foo = 0 # ... more fields and I have some commandline options that can specify better values for things in the header, such as foo. If I try...
0
by: Adisorn Ratanakovit | last post by:
When you set up a full-text catalog in SQL Server and you set up the population schedule, a job gets created and scheduled under SQL Server Agent. The problem I encountered recently is when I...
0
by: Denise | last post by:
Hi I have set up a full text index on one of my database tables and created a catalog. Then I started a full population on my catalog and got a message "Population of full text index started...
0
by: Megan | last post by:
Data Comparison: Sample Versus Rest of Population. I have a population of data, and I want to take a sample of that population and compare it against the entire population. I have a database...
5
by: Paul | last post by:
Hi, I am a self taught VBA programmer, and I'm trying to learn VB2005 Express (The price was right). I like the look of the treeview control, and I'd like to use it as a menu system for my users,...
5
by: Paul Anderson | last post by:
I have a newbie question that I hope someone can answer. VB Studio 2005 I have a form with a button and a listbox. When the button is pressed the following routine is run: Public Class Form1...
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...
1
by: Clive Swan | last post by:
Hi I am trying to sum a population field that may have 140 records for each Ward (example). Any suggestions on the best way to do this. I would like to have a unique record for each Ward...
1
by: tg | last post by:
http://img522.imageshack.us/img522/8647/scan10005ci7.jpg As a percentage of world inhabitants, the white population will plummet to a single digit (9.76%) by 2060 from a high-water mark of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.