whileselect y select n enter y or n select kbnextcharAt0

Whileselect y select n enter y or n select

This preview shows page 2 - 3 out of 3 pages.

while(select != 'y' && select != 'n'){System.out.print("\nPlease enter y or n. ");select = kb.next().charAt(0);}}while(select == 'y');System.out.print("\nWould you like to do another farm?(y/n) ");select = kb.next().charAt(0);while(select != 'y' && select != 'n'){System.out.print("\nPlease enter y or n. ");select = kb.next().charAt(0);}}while(select == 'y');}
Background image
public static int bunnyCounter(int pOld, double g,int carryCap, int months, boolean header){double bOld;double bNew;int pNew = 0;boolean table = false;for(int i=0;i<months;++i){bOld = (double) pOld / carryCap;bNew = bOld + g * bOld * (1 - bOld);pNew = (int) Math.round(bNew * carryCap);pOld = pNew;if(header){System.out.print("Months");System.out.print("\tPopulation\n");table = true;header = false;}if(table){System.out.print(i + 1);System.out.print("\t\t\t" + pNew + "\n");}}return pNew;}public static int monthCounter(int pOld, double g,int carryCap, int desiredPop, boolean header){int months = 0;double bOld = (double) pOld/carryCap;double bNew;double total = 0;int pNew = 0;boolean table = false; while(pNew < desiredPop){bOld = (double) pOld/carryCap;bNew = bOld + g * bOld * (1 - bOld);pNew = (int) Math.round(bNew * carryCap);pOld = pNew;++months;if(header){System.out.print("Months");System.out.print("\tPopulation\n");table = true;header = false;}if(table){System.out.print(months);System.out.print("\t\t\t" + pNew + "\n");}}return months; }}
Background image

You've reached the end of your free preview.

Want to read all 3 pages?

  • Spring '14

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture