Eugene123
10-09-2005, 09:31 PM
Ok, so I'm a complete newbie to programming at all. I'm trying to figure out this problem and have spent a considerable ammount of time trying to figure it out. I'm sure it's very easy, but I really don't know where to start. Anyway I need to display the letter grade for each exam using a for loop with nested if statement. This is the best I've come up with which doesn't work.
for(int i = 0; i < 5; i++)
if (i >= 90)
System.out.println("Letter Grade A" );
Here's the array code
public class ArrayDemo
{
public static void main(String[] args)
{ // declare an int array with 5 elements
int testScores[] = new int [5];
// populate the elements
testScores[0] = 75;
testScores[1] = 80;
testScores[2] = 70;
testScores[3] = 85;
testScores[4] = 90;
// display the element contents
System.out.println("test score 1 = " + testScores[0]);
System.out.println("test score 2 = " + testScores[1]);
System.out.println("test score 3 = " + testScores[2]);
System.out.println("test score 4 = " + testScores[3]);
System.out.println("test score 5 = " + testScores[4]);
for(int i = 0; i < 5; i++)
if (i >= 90)
System.out.println("Letter Grade A" );
Here's the array code
public class ArrayDemo
{
public static void main(String[] args)
{ // declare an int array with 5 elements
int testScores[] = new int [5];
// populate the elements
testScores[0] = 75;
testScores[1] = 80;
testScores[2] = 70;
testScores[3] = 85;
testScores[4] = 90;
// display the element contents
System.out.println("test score 1 = " + testScores[0]);
System.out.println("test score 2 = " + testScores[1]);
System.out.println("test score 3 = " + testScores[2]);
System.out.println("test score 4 = " + testScores[3]);
System.out.println("test score 5 = " + testScores[4]);