At the bottom I attempted to create several arrays but I'm not sure if there correct.
View the step-by-step solution to:

Question

Hi,

I really need help on the array part of my homework. At the bottom I attempted to create several arrays

but I'm not sure if there correct. In addition, I was hoping for someone to look over my code, and see if I'm on the right path. I place comments right by the codes.Thank in advance.:


Homework:


Make a program that does the following:

  1. Make an array of 100 integers.
  2. Store 100 random integers (between 1 and 100) in the array.
  3. Print out the elements of the array.
  4. Sort the array in ascending order.
  5. Print out the sorted array.
  6. Prompt the user to enter a number between 1 and 100. Search the array for that number and then display "Found" or "Not Found" message.
  7. Display each number from 1 to 100 and the number of times each is found in the array.
  8. Display the average of the numbers in the array.
  9. Display the highest number in the array.
  10. Display the lowest number in the array.

Other requirements.

  1. Everything should be done using METHODS.
  2. NO NEED FOR A MENU SYSTEM. Just call the methods in the sequence above.
  3. Add your design tool to your project.

Submission Requirements:

  • You must follow the rules from the previous assignment.

YOU MAY NOT EVER:

  • Use global variables.
  • Use the word goto.
  • Use the break command outside a case statement.


Here what I did so far:



import java.util.Scanner;



public class Arrays {

public static void main(String[] args) {

int[] a = new int[100];

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

a[i] = (int)(Math.random()*100) + 1;// I found this code online to help me with random numbers.

}

printArray(a);// I was trying to get the print/sort array here but I got confused. Please help.

sortArray(a);

printArray(a);

System.out.println("enter a number between 1 and 100");

Scanner array = new Scanner(System.in);//user input

int creature = array.nextInt();

}

}

Top Answer

The java code can be... View the full answer

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question