473,789 Members | 2,634 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Population and Class

5 New Member
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 2894
dexterdreads
5 New Member
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.Scann er;

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.prin t("\nEnter the number of organisms: ");
startPop = kb.nextInt();

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

//Get the number of days for multiplying
System.out.prin t("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.prin tln("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.prin tln("Would you like to enter numbers again? ");
System.out.prin t("Enter Y for yes or N for no: ");
input = kb.next();
YN = input.charAt(0) ;

}

}



}
May 4 '07 #2
Ganon11
3,652 Recognized Expert Specialist
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
dexterdreads
5 New Member
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
2018
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 the obvious (to me): parser = optparse.OptionParser() parser.add_option('--secret', type='string', dest='header', default=Header())
0
2185
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 disabled that job in SQL Server Agent, the full-text catalog continues to be populated with that schedule (every 15 minutes). So I looked at the catalog's properties and noticed that the schedule is still marked as enabled. I deleted that schedule...
0
3029
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 successfully". However the catalog status has remained idle and its item count is 0. When i try to call on the full-text columns i get the following error message: -
0
3742
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 that records information about the types of Rulings a person receives. Each person works for an agency, and there are 12 agencies (see example below). Each person receives a ruling, and there are 2 types of rulings,
5
5823
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, the options they are allowed to see are all different and specified in a MSACCESS table. Can I populate a Treeview directly from my MSAccess table ? I can then of course filter the table to only show that users options.
5
1372
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 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i As Integer
14
16846
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 population of organisms. The program should ask for the starting number of organisms, their average daily population increase (as a percentage), and the number of days they will multiply. For example, a population might begin with two organisms, have an...
1
2008
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 with all the records summed.
1
4671
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 27.98% in 1950. The big population story of the 21st Century is shaping up to be the status reversal of whites and blacks and the Indian baby boom. A side bar will be the single digit minority role that whites will assume. Of the 7 population groups...
0
10195
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9016
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6765
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5415
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4090
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3695
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2906
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.