Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

1. ## Counter troubles

/**
Hey guys im new to java programming and have an assigment to write a code to calculate the current population of a organism.
My problem is i cannot figure out how use my updated population size, he counter just keeps on calulating the population size of the
given number . ( Hope this is clear run the program and my problem wil be obvious)
*/

import java.util.Scanner;

public class Population
{
public static void main(String[] args)
{
double popsize;
double averagepopincrease;
double days;

Scanner keyboard = new Scanner(System.in);
System.out.println("Please enter the number of organisms");
popsize = keyboard.nextDouble();
if(popsize < 2)
System.out.println( "Must be atleast 2 oranisms");

Scanner keyboard1 = new Scanner(System.in);
System.out.println("Please enter the population increase as a decimal");
averagepopincrease = keyboard1.nextDouble();
if(averagepopincrease <= 0)
System.out.println( "Average Population increase cannot be a negative number");

Scanner keyboard2 = new Scanner(System.in);
System.out.println("Please enter the amount of days you wish to calculate");
days = keyboard2.nextDouble();

for( days = 1; days <= 10; days++)
{
System.out.println((popsize * averagepopincrease) + popsize);

}
}
}

2. ## Re: Counter troubles

When posting code, please use the highlight tags to preserve formatting.

Why are you creating multiple scanners?

When do you take into account which day it is? When do you actually change the population? You're only using the initial values.