Write a Java application that does the following:
Reads an integer from the user represents the number of the students in a class.
Reads the scores of the students from the user and store them in an array.
Calculates and prints the percentage of the excellent students in the class rounded
to 1 decimal place.
please i am new at programming and have to submit this assignment by tomorrow.. so can how how to write.. coz the way i am using it keeps messing up at the declaring Array time
Re: i need help writing a program using array. ASAP!
this what i have so far.. i just started java this semester so i bet its full of mistakes.
import java.util.Scanner;
public class Q7_A_112532 {
public static void main(System[] args){
Scanner input = new Scanner(System.in);
int num = 0;
int excellentstudent;
excellentstudent = 0;
double percentage = 0;
System.out.print("enter the total number of students: ");
num = input.nextInt();
int[] studentarray;
studentarray = new.int[num];
{for (i = 0; i < studentarray.lenght, i++ )
sum = sum + arr[num]
}
if (grade >= 90 )
gradecount ++;
percentage = count * 100 / num
System.out.printf("The percentage f excellent student is : %.1f", + percentage);
Re: i need help writing a program using array. ASAP!
okay i get that part... but now its not even running.... it says that it doesn't have a main method. Could you do me the biggest favor and go through the code once... and tell me if u think what i am trying to do is right or not.... you see the thing is i srudy in an arab country where majority of my class speaks Arabic... so our professor is compelled to speak Arabic most of the time... and that is how i miss those small points that make these programs work.
Re: i need help writing a program using array. ASAP!
okay i get that part... but now its not even running
It can't have been running before, it wouldn't compile.
Post your latest code with all these fixes in place - please use code tags when posting code.
Your code is on the right lines - you are missing the bit where you ask the user of each of the scores but the rest looks basically correct.
What are grade and gradeCount for - they are not part of the question you posted.
Re: i need help writing a program using array. ASAP!
okY so i got the errors down to 5.. here the new code so far... i forgot to give a option for the user to enter grade..
import java.util.Scanner;
public class Q7_A_112532 {
public static void main(System[] args){
Scanner input = new Scanner(System.in);
int num = 0;
int excellentstudent;
excellentstudent = 0;
double percentage = 0;
int grade;
System.out.print("enter the total number of students: ");
num = input.nextInt();
int i;
int studentarray;
studentarray = new.int[num];
{for (i = 0; i < studentarray.length, i++ )};
sum = sum + arr[num];
System.out.print("Enter the grade of the student: ");
grade = input.nextInt();
if (grade >= 90 )
gradecount ++;
percentage = count * 100 / num;
System.out.printf("The percentage f excellent student is : %.1f", + percentage);
Bookmarks