Can i please get help in this Introductory Java HomeworkPlea

Can i please get help in this Introductory Java Homework?Please avoid using advace concept as its an intro course. (Sorry for all these photos, The code wont take you much time as its a basic 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

*/

Modification Instructions:

Indentation and Comment writing instructions(please follow these when indenting or commenting:

Solution


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;
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;

  
double growthFactor;
growthFactor = Math.sqrt( (double)matingPairs);

  
DecimalFormat threeDigits = new DecimalFormat(\"0.000\");


double ratioFactor;
if (sexRatio != 0)
   ratioFactor = growthFactor / sexRatio;
else
   ratioFactor = Math.sqrt(ratioVariance);

  
DecimalFormat oneDigit = new DecimalFormat(\"0.0\");


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

System.out.println(\"\ Total Butterflies: \" + totalButterflies );
System.out.println(\"Sex Ratio : \" + sexRatio );
System.out.println(\"Variance : \" + ratioVariance );
System.out.println(\"Difference : \" + genderDifference );
System.out.println(\"Pairs : \" + matingPairs );
System.out.println(\"Growth Factor : \" + threeDigits.format(growthFactor) );
System.out.println(\"Ratio Factor : \" + oneDigit.format(ratioFactor) );
System.out.println(\"Potential Population : \" + (int) potentialPopulation );
}
}

Can i please get help in this Introductory Java Homework?Please avoid using advace concept as its an intro course. (Sorry for all these photos, The code wont ta
Can i please get help in this Introductory Java Homework?Please avoid using advace concept as its an intro course. (Sorry for all these photos, The code wont ta
Can i please get help in this Introductory Java Homework?Please avoid using advace concept as its an intro course. (Sorry for all these photos, The code wont ta

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site