Please avoid using advace concept as its an intro JAVA cours

Please avoid using advace concept as its an intro JAVA course. This code needs to be modified with the following changes given. Please put in proper comments and identation. (instructions are given). Ill definetly give you a thumbs up rating. Thanks!

Code to be modified:

import java.util.Scanner;

public class Hwk3 {

public static void main (String[] args) {

  

int males, females;

int totalButterflies, sexRatio, ratioVariance,genderDifference, matingPairs;

Scanner stdin = new Scanner(System.in);

System.out.println(\"\ Butterfly Estimator\ \");

System.out.print(\"Enter the estimated males population: \");

males = stdin.nextInt();

System.out.print(\"Enter the estimated females population: \");

females = stdin.nextInt();

totalButterflies = males + females;

sexRatio = males / females;

ratioVariance = males % females;

genderDifference = males-females;

matingPairs = males*females;

  

System.out.println(\"\ Total Butterflies: \" + totalButterflies );

System.out.println(\"Sex Ratio : \" + sexRatio );

System.out.println(\"Variance : \" + ratioVariance );

System.out.println(\"Gender Difference: \" + genderDifference );

System.out.println(\"Mating Pairs : \" + matingPairs );

}

}

/*

Sample Output:

Butterfly Estimator

Enter the estimated males population: 33

Enter the estimated females population: 22

Total Butterflies: 55

Sex Ratio : 1

Variance : 11

Gender Difference: 11

Mating Pairs : 726

*/

Instructions:

Also please write comments and use proper indentation:

Here are some instructions to guid ya:

Solution

Hi, Please find my code.

import java.text.DecimalFormat;

import java.util.Scanner;

public class Hwk3 {

public static void main (String[] args) {

  

int males, females;

int totalButterflies, sexRatio, ratioVariance,genderDifference, matingPairs;

  

// declaring variables

double growthFactory, ratioFactor, potentialPopulation;

  

Scanner stdin = new Scanner(System.in);

System.out.println(\"\ Butterfly Estimator\ \");

System.out.print(\"Enter the estimated males population: \");

males = stdin.nextInt();

System.out.print(\"Enter the estimated females population: \");

females = stdin.nextInt();

totalButterflies = males + females;

sexRatio = males / females;

ratioVariance = males % females;

genderDifference = males-females;

matingPairs = males*females;

  

// calculating Growth Factory

growthFactory = Math.sqrt(matingPairs);

  

// calculating Ration factor

if(sexRatio == 0){

   ratioFactor = Math.sqrt(ratioVariance);

}else{

   ratioFactor = growthFactory/sexRatio;

}

  

// calculating Potential population

potentialPopulation = Math.pow(2, (int)ratioFactor);

  

// creating DecimalForamt class object

DecimalFormat df1 = new DecimalFormat(\"#.000\"); // three point display

DecimalFormat df2 = new DecimalFormat(\"#.0\"); // 1 point display

DecimalFormat df3 = new DecimalFormat(\"#.#\"); // no point display

  

System.out.println(\"\ Total Butterflies: \" + totalButterflies );

System.out.println(\"Sex Ratio : \" + sexRatio );

System.out.println(\"Variance : \" + ratioVariance );

System.out.println(\"Gender Difference: \" + genderDifference );

System.out.println(\"Mating Pairs : \" + matingPairs );

System.out.println(\"Growth Factory :\"+ df1.format(growthFactory));

System.out.println(\"Ration Factor :\"+df2.format(ratioFactor));

System.out.println(\"Potential Population:\"+df3.format(potentialPopulation));

}

}

/*

Sample Output:

Butterfly Estimator

Enter the estimated males population: 45

Enter the estimated females population: 34

Total Butterflies: 79

Sex Ratio : 1

Variance : 11

Gender Difference: 11

Mating Pairs : 1530

Growth Factory :39.115

Ration Factor :39.1

Potential Population:549755813888

*/

Please avoid using advace concept as its an intro JAVA course. This code needs to be modified with the following changes given. Please put in proper comments an
Please avoid using advace concept as its an intro JAVA course. This code needs to be modified with the following changes given. Please put in proper comments an
Please avoid using advace concept as its an intro JAVA course. This code needs to be modified with the following changes given. Please put in proper comments an
Please avoid using advace concept as its an intro JAVA course. This code needs to be modified with the following changes given. Please put in proper comments an

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site