Hi i just need each of these two codes to be properly IDENTE

Hi, i just need each of these two codes to be properly IDENTED. The instructions are given and so are the codes. Appreciate the help . Thanks! I\'ll def give a thumbs up :)!

Instructions:

Code 1:

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;

  


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;

  


growthFactory = Math.sqrt(matingPairs);

  

if(sexRatio == 0){

ratioFactor = Math.sqrt(ratioVariance);

}else{

ratioFactor = growthFactory/sexRatio;

}

  


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


DecimalFormat df1 = new DecimalFormat(\"#.000\");

DecimalFormat df2 = new DecimalFormat(\"#.0\");

DecimalFormat df3 = new DecimalFormat(\"#.#\");


  

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

}

}

1)

Sample Output:


Butterfly Estimator

Enter the estimated males population: 50
Enter the estimated females population: 15

Total Butterflies: 65
Sex Ratio : 3
Variance : 5
Gender Difference: 35
Mating Pairs : 750
Growth Factory :27.386
Ration Factor :9.1
Potential Population:512

2).
Butterfly Estimator

Enter the estimated males population: 10
Enter the estimated females population: 1

Total Butterflies: 11
Sex Ratio : 10
Variance : 0
Gender Difference: 9
Mating Pairs : 10
Growth Factory :3.162
Ration Factor :.3
Potential Population:1

3).
Enter the estimated males population: 1
Enter the estimated females population: 10

Total Butterflies: 11
Sex Ratio : 0
Variance : 1
Gender Difference: -9
Mating Pairs : 10
Growth Factory :3.162
Ration Factor :1.0
Potential Population:2

Code 2:

import java.util.*;
class Series
{

public static void main(String ar[])

{
int series[]=new int[100];

int i=0,max,min;

Scanner s=new Scanner(System.in);

System.out.print(\"Enter any one number\");

series[i]=s.nextInt();
min=series[i];

max=series[i];

while(series[i]!=-1)
{
i++;
System.out.print(\"Enter any one number\");

series[i]=s.nextInt();

if(series[i]>max)
max=series[i];

if(series[i]!=-1 && series[i] min=series[i];
}
System.out.println(\"Larget number is \"+max);

System.out.println(\"Smallest number is \"+min);
}
}

Output:
First Run:

Enter any one number:85
Enter any one number:95
Enter any one number:65
Enter any one number:-1
Largest number is 95
Smallest number is 65

1.4 Indentation The open curly\"\"is called: begin. The\"\" can be placed in two possible ways by convention 1. at the end of the line it begins, or 2. in the same first column on the subsequent line The close curly \")\" is called: end. The end must be placed underneath in the same first column as the corresponding begin line Every text book in every language indents the code the same way. All books on programming do the same. Guideline: Statements between begin\"\" and end\")\" must have proper indentation by convention The indentation factor is the number of spaces used, and should be at least 2 but not more than 8. You need to know the three rules for indentation: 1. Whenever there is a begin \"\" then indent 2. Whenever there is an end \"\" then return to the previous level of indentation 3. Do not change indentation otherwise

Solution

Please find INDENDENT Code

1)

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;


       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;


       growthFactory = Math.sqrt(matingPairs);

       if(sexRatio == 0) {
           ratioFactor = Math.sqrt(ratioVariance);
       }else {
           ratioFactor = growthFactory/sexRatio;
       }


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

       DecimalFormat df1 = new DecimalFormat(\"#.000\");
       DecimalFormat df2 = new DecimalFormat(\"#.0\");
       DecimalFormat df3 = new DecimalFormat(\"#.#\");


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

2)

import java.util.*;
class Series {
   public static void main(String ar[]) {
       int series[]=new int[100];
       int i=0,max,min;
       Scanner s=new Scanner(System.in);
       System.out.print(\"Enter any one number\");
       series[i]=s.nextInt();
       min=series[i];
       max=series[i];
       while(series[i]!=-1) {
           i++;
           System.out.print(\"Enter any one number\");
           series[i]=s.nextInt();
           if(series[i]>max)
               max=series[i];
           if(series[i]!=-1 && series[i] min=series[i];
       }
       System.out.println(\"Larget number is \"+max);
       System.out.println(\"Smallest number is \"+min);
   }
}

Hi, i just need each of these two codes to be properly IDENTED. The instructions are given and so are the codes. Appreciate the help . Thanks! I\'ll def give a
Hi, i just need each of these two codes to be properly IDENTED. The instructions are given and so are the codes. Appreciate the help . Thanks! I\'ll def give a
Hi, i just need each of these two codes to be properly IDENTED. The instructions are given and so are the codes. Appreciate the help . Thanks! I\'ll def give a
Hi, i just need each of these two codes to be properly IDENTED. The instructions are given and so are the codes. Appreciate the help . Thanks! I\'ll def give a
Hi, i just need each of these two codes to be properly IDENTED. The instructions are given and so are the codes. Appreciate the help . Thanks! I\'ll def give a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site