Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello, I need help in this intro to Java homework. It needs to be updated the in

ID: 3923778 • Letter: H

Question

Hello,

I need help in this intro to Java homework. It needs to be updated the instructions are given. Pleasse avoide any Advanced concepts such as arrays etc as its very basic hw.. Ill be sure to leave a thumbs up ,just be sure to follow all the instructions please.

Code to be updated:

import java.util.Scanner;
public class HwkSample {
public static void main (String[] args) {
    int males, females;
    int totalButterflies, sexRatio, ratioVariance;
    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;
    
    System.out.println(" Total Butterflies: " + totalButterflies );
    System.out.println("Sex Ratio        : " + sexRatio );
    System.out.println("Variance         : " + ratioVariance );
}
}
Here is a sample to show how to run the program:
bash-3.00$ java HwkSample                                                  

Butterfly Estimator

Enter the estimated males population: 33
Enter the estimated females population: 22

Total Butterflies: 55
sex Ratio        : 1
Variance         : 11

Instructions:

Explanation / Answer

Hi, Please find my code.

Please let me know in case of any issue.

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

*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote