Here is the Question
Declare an array of size 5
Input 5 values from the user
Output those 5 values back.
Output looks like following:
Enter a value: 2
Enter a value: 4
Enter a value: 6
Enter a value: 7
Enter a value: 9
You have entered:
2
4
6
7
9
and now i have 2 errors on line 16 one is an illegal start of expression and one says it is expected a ) all on line 16 please help me fast!!!!!!!!
and here is what i have so far
public class MakeArrays
{
public static void main(String[]args)
{
final int NUMBER_OF_ELEMENTS =5;
double[] numbers = new double[NUMBERS_OF_ELEMNTS];
java.util.Scanner input=new java.util.Scanner(System.in);
for(int i=0; i<NUMBER_OF_ELEMENTS;)
{
// The user will enter 2,4,6,7,9
System.out.print("Enter the new number. That is 2,4,6,7,9:");
double temp=input.nextDouble();
if(temp=1|| temp=2|| temp=4|| temp=8|| temp=7|| temp=9)
{
numbers[i]=temp;
i++;
System.out.println("You have entered.");
}
}
//This part to count numbers of 2's,4's,6's,7's, and 9's
int count2=0,count4=0,count6=0,count7=0,count9=0;
for(int i=0; i<NUMBER_OF_ELEMNTS; i++)
{
if(numbers[i]==2)
count2++;
if(numbers[i]==4)
count4++;
if(numbers[i]==6)
count6++;
if(numbers[i]==7)
count7++;
if(numbers[i]==9)
count9++;
}
//This is to display the numbers of 2's,4's,6's,7's,9's
System.out.println("Enter a value"+count2+"2's.");
System.out.println("Enter a value"+count4+"4's.");
System.out.println("Enter a value"+count6+"6's.");
System.out.println("Enter a value"+count7+"7's.");
System.out.println("Enter a value"+count9+"9's.");
}
}