0

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?

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by moutanna
0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.