I was wondering if it's possible to use a loop to fill and array without prompting the user for input? I have to design a program to fill an array of size 6 with multiples of 7. The specification doesn't say anything about prompting the user, and it says 'Use a loop to fill the array' so I can't hard code the numbers in. Of the multiples of 7 , I need to print out which ones can be divided by 3 exactly.
Is it possible to fill the array without an input from the user? My code is below...
import java.util.Scanner;
/**
* Created by IntelliJ IDEA.
* Date: 26/02/2015
* Time: 15:25
* UPDATE COMMENT ABOUT PROGRAM HERE
*/
public class Array7Mult
{
public static void main(String[] args)
{
int multipleSeven [] = new int[6];
final int HOWMANY=6,DIVIDE=3;
Scanner keyboard = new Scanner(System.in);
for(int count=0;count<HOWMANY;count++)
{
System.out.println("Please enter a multiple of 7 below..");
multipleSeven[count]=keyboard.nextInt();
}//for
System.out.println("The multiples of seven that can be divided by 3 are..");
for(int count=0;count<HOWMANY;count++)
{
if (multipleSeven[count] % DIVIDE == 0)
{
System.out.println(multipleSeven[count]);
}//if
}//for
}//main
}//class
int multipleSeven []is discoraged useint[] multipleSevenfor the declaration.