Population - JOptionPane.showMessageDialog(null,"The...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import javax.swing.JOptionPane; public class Population { public static void main(String[]args) { String p = JOptionPane.showInputDialog(null,"Enter the starting population "); String b = JOptionPane.showInputDialog(null,"Enter the starting birth rate "); String d = JOptionPane.showInputDialog(null,"Enter the starting death rate "); String n = JOptionPane.showInputDialog(null,"Enter the starting number of years "); int startPopulation = Integer.parseInt(p); int startBirthrate = Integer.parseInt(b); int startDeathrate = Integer.parseInt(d); int startYearnumber = Integer.parseInt(n); int popGrowthrate = startBirthrate - startYearnumber; int estimatedPop = startPopulation + startBirthrate*startPopulation/100 - startDeathrate*startPopulation/100;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: JOptionPane.showMessageDialog(null,"The growth rate is " + growthRate(startBirthrate,startDeathrate)); JOptionPane.showMessageDialog(null,"The estimated Population is " + estimatedPopulation (startPopulation,popGrowthrate,startYearnumber,estimatedPop)); ( if(startDeathrate%startYearnumber<0) JOptionPane.showMessageDialog(null,"The number you entered is invalid"); if(startPopulation<2) JOptionPane.showMessageDialog(null,"The number you entered is invalid"); J } public static int growthRate(int sB,int sD) { int populationGrowth = sB - sD; return populationGrowth; } public static int estimatedPopulation(int sP,int pG,int sY,int eP) { while(eP<=5000) { eP++; } return eP; }} }...
View Full Document

This note was uploaded on 10/04/2010 for the course COMPUTER S 106 taught by Professor Moore during the Spring '08 term at Clark Atlanta.

Ask a homework question - tutors are online