Question:

Create a java program that can compute for the multiple of 5 from 1 to 20 using an array.....plz help me...^^?

by  |  earlier

0 LIKES UnLike

i really have no idea when it comes to programming......plz help me out guyz...^^

 Tags:

   Report

2 ANSWERS


  1. coding for project-

    http://codingforum.info/    


  2. I started to write a code snippet for you, but realized you have a few too many undefined bits to your question.

    1) Does the array need to store the integers 1-20 or the multiples of 5? This either makes it an array of 20 elements or an array of 4 elements.

    2) Are you including the integer 20 in that computation?

    3) What do you need to happen when a multiple of 5 is found? Display the value, put it in an array, increment a counter?

    I'll take some liberties here...First obtain or create the array. If it's an array of 20 elements:

                                  int[] numberArray = new int[20];

    Now fill up your array if you have to:

                  for (int i = 0; i < numberArray.length; i++){

                         numberArray[i] = i + 1;

                  }

    Here's where I don't know what you need to do with the multiples. You can use the same type of loop as above to do a few different things. You can use a switch statement (some logic that says "if the number in question is 5, 10, 15, or 20, do this action. Otherwise, do that action") to increment a counter, display the value, or put the value into another array, among many other things you could do when you find a value that fits the criteria.

    A switch statement tutorial can be found at http://java.sun.com/docs/books/tutorial/...

    General java tutorials can be found at http://java.sun.com/docs/books/tutorial/...

    I would be glad to elaborate on a more appropriate solution if you provide all the details of what you are trying to do, exactly.

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.