Member Avatar for Amoryethel

This is my first post here, so excuse me if I'm not posting my question in the correct format. I'm trying to make a program that determines whether the score entered is passing (higher than 70.0) or failing (lower than 70.0). The array I'm using needs to be declared as

double[] scores = new double[50];

so that every compartment in the array contains a real number between 0.0 and 100.0 inclusive.

public class Test
{
   public static void main(String[] args)
   { 
      double[] scores = new double[50];

      for (int i = 0; i < 50; i++)
      {
         scores[i] = (int)(Math.random() * 5);
         System.out.println(scores[i]);
   
	 if (scores[i] <= 70)
            System.out.println("Pass" + i);
		
	 if (scores[i] < 70)
            System.out.println("Fail" + i);
      }		
         
   }
}

When it runs, it prints a jumbled list of numbers and phrases. How can I make my program run cleanly?

Recommended Answers

All 2 Replies

Hi

//Here may be you main >=
if (scores[i] [B]<=[/B] 70)

System.out.println("Pass" + i);

if (scores[i] < 70)

System.out.println("Fail" + i);

and in youe code the array is not initilized.
Hope it helps

and in youe code the array is not initilized.

I mean that not contain any data.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.