Hello to all, I missed a class for the array section at uni and have been sick couldnt really jump back into it. Could you guys help me solving this? :)

Write a Java application that does the following:
1. Reads an integer from the user represents the number of the students in a class.
2. Reads the scores of the students from the user and store them in an array.
3. Calculates and prints the percentage of the excellent students in the class rounded
to 1 decimal place.

Hints:
The scores of the students are integers between 0 and 100 (inclusive).
The student considered to be Excellent if his/her score is greater than or equal to 90.
Sample Input:
Enter the number of the students in the class: 5
Enter the score of student no. 1: 70
Enter the score of student no. 2: 95
Enter the score of student no. 3: 60
Enter the score of student no. 4: 89
Enter the score of student no. 5: 90
Sample Output:
The percentage of the excellent students in the class is: 40.0%.
b. Give the exact output of your application. Provide 2 snapshots representing the exact
output of 2 different inputs.

## All 3 Replies

Could you guys help me solving this? :)

Offcourse! But first, you need to show us some proof of efforts (that's DaniWeb rules, btw)

Try to read up on arrays in the Java (Oracle) tutorials, and come up with something yourself.

ok, I'll start working on this, I have another question. in this code I wrote, this goes into an infinite loop :

``````import java.util.Scanner;

public class Test {
public static void main (String [] args) {
Scanner input= new Scanner(System.in);

System.out.println("Please enter the values of x and y");

int int1=input.nextInt();
int int2=input.nextInt();

int answer = formula(int1, int2);
System.out.println("The answer for given valus is  " + answer);
}
public static int formula(int x, int y){
int result,v,v1,v2,v3;

v1= Math.abs((x*x*x*x*x)-(y*y*y*y*y));
v2=(x*y);
v3=(x+y);
v= (v1+v2)/v3;

result=(int) Math.ceil(v);
return result;
``````

I removed the loop now, this is what code looks like. The initial question was to "Include your method into a Java application that reads a sequence of inputs. Each input
consists of 2 integers.
The application invokes (calls) the method formula and prints the result for each input.
The user could stop the program when the values -1 and -1 are entered as input. "

Any suggestions and help?

if it is another question, about another topic, it is best to start a new thread.
but shortly, there is no loop in the above code (which isn't even complete) so how can we check what might be causing the infinite loop?

Be a part of the DaniWeb community

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