Hello,
I hope someone can help me. I had to do the following assignment( i have most of it done just cant finish it off, question and source code below).
Question?
Write a Java program that asks the user to input the scores, as a percentage( e.g 87.4), of 10 students. The scores entered must be stored ina n array.
The programme must determine:
The lowest score and its equivalent grade (ie A,B,etc)
The highest " " " " "
The average score and its "
The bit i cant do is tie in the equivalent grade with the lowest highest and average score.
Code:
[CODE=Java]
//Arrayofscores.j ava
//This programme asks the user to enter 5 exam scores and store them in an array
import java.text.*;
public class Arrayofscores
{
public static void main(String args[])
{
int [] scores = new int[10];
int smallest, highest,temp,to tal=0;
double average =0.0;
//ask the user to enter 10 scores
for (int i = 0;i<= scores.length-1;i++)
{
System.out.prin t("\n\nEnter Score " + (i+1) + ": ");
scores[i] = UserInput.getIn t();
}
//find the lowest score
smallest = scores[0];
for (int i = 1; i <= scores.length-1;i++)
if (scores[i] < smallest)
smallest = scores[i];
System.out.prin tln("\nThe lowest score is : " + smallest);
//find the highest score
highest = scores[0];
for (int i = 1; i <= scores.length-1;i++)
if (scores[i] > highest)
highest = scores[i];
System.out.prin tln("\nThe highest score is : " + highest);
//find the average score
for (int i = 0; i<=scores.lengt h-1;i++)
total = total + scores[i];
average = total/10.0;
System.out.prin tln("\nThe average score is : " + average);
} [/CODE]
}
Any suggestions would be greatly appreciated!!
I hope someone can help me. I had to do the following assignment( i have most of it done just cant finish it off, question and source code below).
Question?
Write a Java program that asks the user to input the scores, as a percentage( e.g 87.4), of 10 students. The scores entered must be stored ina n array.
The programme must determine:
The lowest score and its equivalent grade (ie A,B,etc)
The highest " " " " "
The average score and its "
The bit i cant do is tie in the equivalent grade with the lowest highest and average score.
Code:
[CODE=Java]
//Arrayofscores.j ava
//This programme asks the user to enter 5 exam scores and store them in an array
import java.text.*;
public class Arrayofscores
{
public static void main(String args[])
{
int [] scores = new int[10];
int smallest, highest,temp,to tal=0;
double average =0.0;
//ask the user to enter 10 scores
for (int i = 0;i<= scores.length-1;i++)
{
System.out.prin t("\n\nEnter Score " + (i+1) + ": ");
scores[i] = UserInput.getIn t();
}
//find the lowest score
smallest = scores[0];
for (int i = 1; i <= scores.length-1;i++)
if (scores[i] < smallest)
smallest = scores[i];
System.out.prin tln("\nThe lowest score is : " + smallest);
//find the highest score
highest = scores[0];
for (int i = 1; i <= scores.length-1;i++)
if (scores[i] > highest)
highest = scores[i];
System.out.prin tln("\nThe highest score is : " + highest);
//find the average score
for (int i = 0; i<=scores.lengt h-1;i++)
total = total + scores[i];
average = total/10.0;
System.out.prin tln("\nThe average score is : " + average);
} [/CODE]
}
Any suggestions would be greatly appreciated!!
Comment