I am trying to reverse this array by copying it to a new array andmy prof told m
ID: 3614925 • Letter: I
Question
I am trying to reverse this array by copying it to a new array andmy prof told me to embed my method "reverse" to this java file andsomehow have it display the array before and after I call themethod "reverse" I want to say you use the swap method totemporarily find a place for the third to store but don'treally know where to stick the code ...Below is my java program but can you tell me how to addreverse?
import javax.swing.JOptionPane;
public class MyLAB9 {
public static void main(String[] args) {
// Get array size String numStr = JOptionPane.showInputDialog("How many randomnumbers?"); int numRandom = Integer.parseInt(numStr);
// Create an integer array, myArray, with the size ofnumRandom int[] myArray = new int[numRandom];
// Call method "arrayData" to fill the array arrayData(myArray);
// Call method "arrayDisplay" to display the array arrayDisplay(myArray);
// Call method "array60" to deterine how many 60+ in thearray array60(myArray); } // end of main
// Fill the array with random integers between 1 and 100 public static void arrayData(int[] arrayOne) { for (int i = 0; i < arrayOne.length; i++) arrayOne[i] = (int) (Math.random()*100) + 1; } // end of arrayOne
// Display the array contents public static void arrayDisplay(int[] arrayTwo) { for (int i =0; i < arrayTwo.length; i++) System.out.println("myArray[" + i +"] = " +arrayTwo[i]); } // end of arrayDisplay
// Determine how many 60+ in the array public static void array60(int[] arrayThree) { int count = 0; for (int i = 0; i < arrayThree.length; i++) if (arrayThree[i] >= 60) count = count + 1; System.out.println("There are " + count + " numbers equal toor larger than 60."); System.out.printf("The percentage is %4.1f ",((double)count/arrayThree.length)*100); } // end of array60 }
Below is my java program but can you tell me how to addreverse?
import javax.swing.JOptionPane;
public class MyLAB9 {
public static void main(String[] args) {
// Get array size String numStr = JOptionPane.showInputDialog("How many randomnumbers?"); int numRandom = Integer.parseInt(numStr);
// Create an integer array, myArray, with the size ofnumRandom int[] myArray = new int[numRandom];
// Call method "arrayData" to fill the array arrayData(myArray);
// Call method "arrayDisplay" to display the array arrayDisplay(myArray);
// Call method "array60" to deterine how many 60+ in thearray array60(myArray); } // end of main
// Fill the array with random integers between 1 and 100 public static void arrayData(int[] arrayOne) { for (int i = 0; i < arrayOne.length; i++) arrayOne[i] = (int) (Math.random()*100) + 1; } // end of arrayOne
// Display the array contents public static void arrayDisplay(int[] arrayTwo) { for (int i =0; i < arrayTwo.length; i++) System.out.println("myArray[" + i +"] = " +arrayTwo[i]); } // end of arrayDisplay
// Determine how many 60+ in the array public static void array60(int[] arrayThree) { int count = 0; for (int i = 0; i < arrayThree.length; i++) if (arrayThree[i] >= 60) count = count + 1; System.out.println("There are " + count + " numbers equal toor larger than 60."); System.out.printf("The percentage is %4.1f ",((double)count/arrayThree.length)*100); } // end of array60 } Below is my java program but can you tell me how to addreverse?
import javax.swing.JOptionPane;
public class MyLAB9 {
public static void main(String[] args) {
// Get array size String numStr = JOptionPane.showInputDialog("How many randomnumbers?"); int numRandom = Integer.parseInt(numStr);
// Create an integer array, myArray, with the size ofnumRandom int[] myArray = new int[numRandom];
// Call method "arrayData" to fill the array arrayData(myArray);
// Call method "arrayDisplay" to display the array arrayDisplay(myArray);
// Call method "array60" to deterine how many 60+ in thearray array60(myArray); } // end of main
// Fill the array with random integers between 1 and 100 public static void arrayData(int[] arrayOne) { for (int i = 0; i < arrayOne.length; i++) arrayOne[i] = (int) (Math.random()*100) + 1; } // end of arrayOne
// Display the array contents public static void arrayDisplay(int[] arrayTwo) { for (int i =0; i < arrayTwo.length; i++) System.out.println("myArray[" + i +"] = " +arrayTwo[i]); } // end of arrayDisplay
// Determine how many 60+ in the array public static void array60(int[] arrayThree) { int count = 0; for (int i = 0; i < arrayThree.length; i++) if (arrayThree[i] >= 60) count = count + 1; System.out.println("There are " + count + " numbers equal toor larger than 60."); System.out.printf("The percentage is %4.1f ",((double)count/arrayThree.length)*100); } // end of array60 } import javax.swing.JOptionPane;
public class MyLAB9 {
public static void main(String[] args) {
// Get array size String numStr = JOptionPane.showInputDialog("How many randomnumbers?"); int numRandom = Integer.parseInt(numStr);
// Create an integer array, myArray, with the size ofnumRandom int[] myArray = new int[numRandom];
// Call method "arrayData" to fill the array arrayData(myArray);
// Call method "arrayDisplay" to display the array arrayDisplay(myArray);
// Call method "array60" to deterine how many 60+ in thearray array60(myArray); } // end of main
// Fill the array with random integers between 1 and 100 public static void arrayData(int[] arrayOne) { for (int i = 0; i < arrayOne.length; i++) arrayOne[i] = (int) (Math.random()*100) + 1; } // end of arrayOne
// Display the array contents public static void arrayDisplay(int[] arrayTwo) { for (int i =0; i < arrayTwo.length; i++) System.out.println("myArray[" + i +"] = " +arrayTwo[i]); } // end of arrayDisplay
// Determine how many 60+ in the array public static void array60(int[] arrayThree) { int count = 0; for (int i = 0; i < arrayThree.length; i++) if (arrayThree[i] >= 60) count = count + 1; System.out.println("There are " + count + " numbers equal toor larger than 60."); System.out.printf("The percentage is %4.1f ",((double)count/arrayThree.length)*100); } // end of array60 }
Explanation / Answer
please rate - thanks import javax.swing.JOptionPane; public class MyLAB9 { public static void main(String[] args) { // Get array size String numStr = JOptionPane.showInputDialog("How many randomnumbers?"); int numRandom = Integer.parseInt(numStr); // Create an integer array, myArray, with the size of numRandom int[] myArray = new int[numRandom]; // Call method "arrayData" to fill the array arrayData(myArray); // Call method "arrayDisplay" to display the array arrayDisplay(myArray); // Call method "array60" to deterine how many 60+ in the array array60(myArray); reverse(myArray); arrayDisplay(myArray); } // end of main // Fill the array with random integers between 1 and 100 public static void arrayData(int[] arrayOne) { for (int i = 0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.