Questions
Please convert this java program to a program with methods please. import java.io.*; import java.util.*; public...

Please convert this java program to a program with methods please.

import java.io.*;
import java.util.*;

public class Number{

public static void main(String[] args) {
  
Scanner scan = new Scanner(System.in);

System.out.println("Enter 20 integers ranging from -999 to 999 : "); //print statement

int[] array = new int[20]; //array of size 20

for(int i=0;i<20;i++){

array[i] = scan.nextInt(); //user input

if(array[i]<-999 || array[i]>999){ //check if value is inside the range

System.out.println("Please enter a number between -999 to 999");
i--;
}
}

// Now we have to create 4 array for odd,even,positive,negative number

int odd = 0; //initializing as zero
int even = 0;
int positive = 0;
int negative = 0;

for(int i=0;i<20;i++){

if(array[i]%2 == 0){ //check if even

even++; //increment
}
if(array[i]%2 != 0){ //check if odd

odd++; //increment
}
if(array[i]>0){ //check if positive

positive++; //increment
}   
if(array[i]<0){ //check if negative

negative++; //increment
}
}

//Now initializing array for all

int[] oddA = new int[odd]; //arrays of required size
int[] evenA = new int[even];
int[] positiveA = new int[positive];
int[] negativeA = new int[negative];

int countOdd = 0; //initializing as zero
int countEven = 0; //for array indexing
int countPositive = 0;
int countNegative = 0;

for(int i=0;i<20;i++){

if(array[i]%2 == 0){ //check if even

evenA[countEven] = array[i]; //Putting value
countEven++;
}
if(array[i]%2 != 0){ //check if odd

oddA[countOdd] = array[i]; //Putting value
countOdd++;
}
if(array[i]>0){ //check if positive

positiveA[countPositive] = array[i]; //Putting value
countPositive++;   
}   
if(array[i]<0){ //check if negative

negativeA[countNegative] = array[i]; //Putting value
countNegative++;   
}
}

//Difference between highest and lowest positive number

int highest = -1000; //Initialize
int lowest = 1000;

for(int i=0;i<20;i++){

if(array[i]>0 && array[i]>highest){ //condition for highest positive number

highest = array[i];
}
if(array[i]>0 && array[i]<lowest){ //condition for lowest positve number

lowest = array[i];
}
}

int diff = highest - lowest; //difference

//Sum of all negative numbers

int sumNegative = 0;

for(int i=0;i<negative;i++){

sumNegative = sumNegative + negativeA[i]; //sum of negative number
}

int input = 0;

do{

System.out.println("Enter your choice : ");

System.out.println("1. The orginal array");
System.out.println("2. The array of all odd numbers");
System.out.println("3. The array of all even numbers");
System.out.println("4. The array of all positive numbers");
System.out.println("5. The array of all negative numbers");
System.out.println("6. The highest and lowest postive value and difference between them");
System.out.println("7. The sum of all negative numbers");
System.out.println("8. Display all positive appearing in positive array whose value is less than 50");
System.out.println("9. Display all even numbers in reverse order");
System.out.println("10. Display all multiples of 5 (positive or negative)");

int choice = scan.nextInt(); //user choice

switch(choice){

case 1 :

for(int i=0;i<20;i++){

System.out.print(array[i]+" ");
}
System.out.println("");
break;

case 2 :

for(int i=0;i<odd;i++){

System.out.print(oddA[i]+" ");
}
System.out.println("");
break;

case 3 :

for(int i=0;i<even;i++){

System.out.print(evenA[i]+" ");
}
System.out.println("");
break;

case 4 :

for(int i=0;i<positive;i++){

System.out.print(positiveA[i]+" ");
}
System.out.println("");
break;

case 5 :

for(int i=0;i<negative;i++){

System.out.print(negativeA[i]+" ");
}
System.out.println("");
break;

case 6 :

System.out.println("The highest positive value is : " + highest);
System.out.println("The lowest positive value is : " + lowest);
System.out.println("The difference between the highest and lowest positve value is : " + diff);
break;

case 7 :

System.out.println("The sum of all negative number is : " + sumNegative);
break;

case 8 :

for(int i=0;i<positive;i++){

if(positiveA[i]<50){

System.out.print(positiveA[i]+" ");
}
}
System.out.println("");
break;

case 9 :

for(int i=even-1;i>=0;i--){

System.out.print(evenA[i]+" ");
}
System.out.println("");
break;

case 10 :

for(int i=0;i<20;i++){

if(array[i]%5 == 0){

System.out.print(array[i]+" ");
}
}
System.out.println("");
break;
}

System.out.println("Do you wish to continue : (1 or 0) : Press 1 to continue : ");

input = scan.nextInt();

}while(input == 1);
}
}

In: Computer Science

During the power stroke of an internal combustion engine, the air-fuel mixture is ignited and the...

During the power stroke of an internal combustion engine, the air-fuel mixture is ignited and the expanding hot gases push on the piston. Fuel efficiency is maximized in this process when the ignited gas is as hot as possible, the gas expands allowing a maximum amount of work to be done, and cooled exhaust gas is released at the end of the cycle. Assuming the engine exhibits the highest efficiency possible, which of the following statements concerning the exhaust gas must be true to avoid violating the second law of thermodynamics?

The exhaust gas must be cooled to the same temperature as the outside air.

The exhaust gas must be at the same pressure as the outside air.

The exhaust gas must be hotter than the outside air temperature.

.

The exhaust gas must be at the same volume as the outside air.

A tray of water is placed into a freezer. As the water cools, its entropy decreases and eventually it turns to ice. Why doesn’t this process violate the second law of thermodynamics?

The entropy of the water decreases, but upon freezing it increases to its previous value.

The process as described does violate the second law of thermodynamics.

The overall entropy increases due to the refrigerator chilling and eventually freezing the water.

When the ice is later taken out and melted, the entropy will increase back to what it was before the tray was put into the freezer

In: Physics

4. Bags of rhinestones that I buy are filled by an automated filling machine, so they...

4. Bags of rhinestones that I buy are filled by an automated filling machine, so they are not perfect. The standard deviation of the number of rhinestones in a bag is 7 rhinestones. Assume that the number of rhinestones in each bag are independent, normal variables.

a) What is the standard deviation of an average number of rhinestones in 25 bags?

b) If the average number of rhinestones is 994, what is the probability that the average fill number of 25 bags is less than 1000.

c) What should the mean fill number of rhinestones be equal to so that the probability that the average of 25 bags is less than 1000 is 0.005.

d) If the mean number of rhinestones is 1009, determine the number of bags that need to be measured such that the probability that the average number of rhinestones is less than 1000 is 0.01.

In: Statistics and Probability

The following table shows part of the probability distribution for the number of boats sold daily...

The following table shows part of the probability distribution for the number of boats sold daily at Boats Unlimited. It is known that the average number of boats sold daily is 1.57. x f(x) 0 0.20 1 0.30 2 0.32 3 ? 4 0.05 5 0.02 Compute the variance and the standard deviation for this probability distribution.

In: Statistics and Probability

The following table shows part of the probability distribution for the number of boats sold daily...

The following table shows part of the probability distribution for the number of boats sold daily at Boats Unlimited. It is known that the average number of boats sold daily is 1.57. x f(x) 0 0.20 1 0.30 2 0.32 3 ? 4 0.05 5 ? Complete the distribution by computing the probabilities of selling 3 nd 5 boats per day.

All boats sell for $2000. What is the standard deviation of the daily revenue of the company?

In: Statistics and Probability

Use the probability distribution to complete parts​ (a) and​ (b) below. The number of defects per...

Use the probability distribution to complete parts​ (a) and​ (b) below. The number of defects per 1000 machine parts inspected Defects 0 1 2 3 4 5 Probability 0.261 0.301 0.242 0.133 0.045 0.018 ​(a) Find the​ mean, variance, and standard deviation of the probability distribution. The mean is:

In: Statistics and Probability

Use the probability distribution to complete parts​ (a) and​ (b) below. The number of defects per...

Use the probability distribution to complete parts​ (a) and​ (b) below. The number of defects per 1000 machine parts inspected Defects 0 1 2 3 4 5

Probability 0.262 0.291 0.240 0.151 0.037 0.019

​(a) Find the​ mean, variance, and standard deviation of the probability distribution.

The mean is

nothing.

​(Round to one decimal place as​ needed.)

The variance is

nothing.

​(Round to one decimal place as​ needed.)

The standard deviation is

nothing.

​(Round to one decimal place as​ needed.)

​(b) Interpret the results.

The mean is

nothing​,

so the average batch of 1000 machine parts has

at least 2 defects.

no defects.

1 or 2 defects.

The standard deviation is

nothing​,

so most of the batches of 1000

differ from the mean by no more than about 1 defect.

do not differ from the mean.

differ from the mean by no more than about 2 defects.

differ from the mean by more than about 2 defects.

​(Round to one decimal place as​ needed.)

In: Statistics and Probability

The cumulative probability distribution for the number of chocolate on a single mini-cookie is given below:...

The cumulative probability distribution for the number of chocolate on a single mini-cookie is given below:

Number of Chocolate Chips (xi) P(X≤xi)
0 0.05
1 0.30
2 0.70
3 0.95
4

1.00

1.

What is the probability that a randomly chosen cookie will contain exactly two chocolate chips? Include 2 decimal places in your answer.

2.

What is the probability that a randomly chosen cookie will contain fewer than three chocolate chips? Include 2 decimal places in your answer.

3.

What is the expected number of chocolate chips per cookie? Include 1 decimal place in your answer.

4.

What is the variance? Include 2 decimal places in your answer.

In: Statistics and Probability

A biased coin has probability of p =0.52 for heads. What is the minimum number of...

A biased coin has probability of p =0.52 for heads. What is the minimum number of coin tosses needed such that there will be more heads than tails with 99% probability.

In: Statistics and Probability

The probability distribution of X, the number of defective tires on a randomly selected automobile checked...

The probability distribution of X, the number of defective tires on a randomly selected automobile checked at a certain station is given by the table. X 0 1 2 3 4 p(X) 0.54 0.16 0.06 0.04 0.2 Table 4: Distribution for defective tires

Use excel to find the answers please! thank you

Find a. E(X) =

b. E(X2) =

c. σX =

In: Statistics and Probability