# Thread: Looping WAY too many times...

1. Member
Join Date
Oct 2010
Posts
22
Rep Power
0

## Looping WAY too many times...

I've been pulling my hair out with this program! Essentially, it is supposed to ask how many students the user wants, and then randomly generate scores for the assignments and tests section, output all of these scores, and finally output a letter grade. Instead, it's looping each section WAY too many times, and I can't for the life of me figure it out. Can anyone please help? I posted what I believe to be the problem, but if nothing is wrong, I'll post each method. Thank you so much for any help!!!!!

Essentially, this is the method that I believe to be causing the problem because it's the only one that's looping more than it should for each student.

Java Code:
```		public int ComputeTestScore()
{
int finalPAT = 0;
for (int n=1; n<=1; n++)
{
}		//End of PAT Section

int finalLOs = 0;
for (int m=1; m<=15; m++)
{
System.out.println("LO "+ m + ": " + grade);
}		//End of LOs Section

int finalMidterms = 0;
for (int o=1; o<=2; o++)
{
System.out.println("Midterm "+ o + ": " + grade);
}		//End of Midterms Section

int finalfE = 0;
for (int p=1; p<=1; p++)
{
}

int OverallTests = 0;
OverallTests = finalfE + finalMidterms + finalPAT + finalLOs;//End of FinalExam Section
return OverallTests;
}```
Last edited by BariMutation; 10-14-2010 at 11:47 PM.

2. Senior Member
Join Date
Oct 2010
Posts
393
Rep Power
7
BariMutation,

I can't see any problem with the code you posted.
Is each method being called numerous times before moving on to the next or is the code doing what is required just more times than expected?

If it is the first case, there is a problem with the called method. If the second case applies, there is a problem with the main method.

Please post the code for the relevant scenario.

Regards.

3. Member
Join Date
Oct 2010
Posts
22
Rep Power
0
Well, it depends - the user could input, say, 3 students. Then the assignment, tests, and letter grade methods out be called (respectively) once for the 1st student. Then again for the 2nd student, and so on. Here is the entire code, and thanks for helping!

Java Code:
```import java.util.*;
import java.util.Random;

{
public static void main (String [] args)
{
Scanner scanner = new Scanner(System.in);
System.out.println("Please enter the number of students.");
int studentNumber = 0;
studentNumber=scanner.nextInt();

for (int i=1; i<=studentNumber; i++)
{
System.out.println("Student " + i + ": ");
newInstance.ComputeAssignmentScore();
newInstance.ComputeTestScore();
}
}
public int ComputeAssignmentScore()
{
Scanner scanner = new Scanner(System.in);

int finalAssignments = 0;
for (int j=1; j<=6; j++)
{
System.out.println("Assignment " + j + ": " + grade);
}		//End of Assignments Section

int finalAttendance = 0;
for (int k=1; k<=1; k++)
{
}	//End of Attendance Section

int finalLabs = 0;
for (int l=1; l<=15; l++)
{
System.out.println("Lab " + l + ": " + grade);
}	//End of Labs Section

int finalQuizzes = 0;
for (int q=1; q<=1; q++)
{
}

int OverallAssignments = 0;
OverallAssignments = finalLabs + finalAttendance + finalAssignments;//Finalizes the overall assignment section

return OverallAssignments;
}

public int ComputeTestScore()
{
int finalPAT = 0;
for (int n=1; n<=1; n++)
{
}		//End of PAT Section

int finalLOs = 0;
for (int m=1; m<=15; m++)
{
System.out.println("LO "+ m + ": " + grade);
}		//End of LOs Section

int finalMidterms = 0;
for (int o=1; o<=2; o++)
{
System.out.println("Midterm "+ o + ": " + grade);
}		//End of Midterms Section

int finalfE = 0;
for (int p=1; p<=1; p++)
{
}

int OverallTests = 0;
OverallTests = finalfE + finalMidterms + finalPAT + finalLOs;//End of FinalExam Section
return OverallTests;
}

{
if (ComputeTestScore() <= 149)
{
System.out.println("The final grade for the student is an F.");
}
else if (ComputeTestScore() <= 164 && ComputeTestScore() >= 150 && ComputeAssignmentScore() <= 779)
{
System.out.println("The final grade for the student is an F.");
}
else if (ComputeTestScore() <= 164 && ComputeTestScore() >= 150 && ComputeAssignmentScore() <=1079 && ComputeAssignmentScore() >= 780)
{
System.out.println("The final grade for the student is a D.");
}
else if (ComputeTestScore() <= 164 && ComputeTestScore() >= 150 && ComputeAssignmentScore() <= 1200 && ComputeAssignmentScore() >= 1080)
{
System.out.println("The final grade for the student is a C.");
}
else if (ComputeTestScore() <= 179 && ComputeTestScore() >= 165 && ComputeAssignmentScore() <= 719)
{
System.out.println("The final grade for the student is an F.");
}
else if (ComputeTestScore() <= 179 && ComputeTestScore() >= 165 && ComputeAssignmentScore() <= 959 && ComputeAssignmentScore() >= 720)
{
System.out.println("The final grade for the student is a D.");
}
else if (ComputeTestScore() <= 179 && ComputeTestScore() >= 165 && ComputeAssignmentScore() >= 960 && ComputeAssignmentScore() <= 1200)
{
System.out.println("The final grade for the student is a C.");
}
else if (ComputeTestScore() <= 194 && ComputeTestScore() >= 180 && ComputeAssignmentScore() <= 659)
{
System.out.println("The final grade for the student is an F.");
}
else if (ComputeTestScore() <= 194 && ComputeTestScore() >= 180 && ComputeAssignmentScore() <=899 && ComputeAssignmentScore() >= 660)
{
System.out.println("The final grade for the student is a D.");
}
else if (ComputeTestScore() <= 194 && ComputeTestScore() >= 180 && ComputeAssignmentScore() <= 1139 && ComputeAssignmentScore() >= 900)
{
System.out.println("The final grade for the student is a C.");
}
else if (ComputeTestScore() <= 194 && ComputeTestScore() >= 180 && ComputeAssignmentScore() <= 1200 && ComputeAssignmentScore() >= 1140)
{
System.out.println("The final grade for the student is a B.");
}
else if (ComputeTestScore() <= 209 && ComputeTestScore() >= 195 && ComputeAssignmentScore() <= 659)
{
System.out.println("The final grade for the student is an F.");
}
else if (ComputeTestScore() <= 209 && ComputeTestScore() >= 195 && ComputeAssignmentScore() >= 660 && ComputeAssignmentScore() <= 839)
{
System.out.println("The final grade for the student is a D.");
}
else if (ComputeTestScore() <= 209 && ComputeTestScore() >= 195 && ComputeAssignmentScore() >= 840 && ComputeAssignmentScore() <= 1079)
{
System.out.println("The final grade for the student is a C.");
}
else if (ComputeTestScore() <= 209 && ComputeTestScore() >= 195 && ComputeAssignmentScore() >= 1080 && ComputeAssignmentScore() <= 1200)
{
System.out.println("The final grade for the student is a B.");
}
else if (ComputeTestScore() <= 224 && ComputeTestScore() >= 210 && ComputeAssignmentScore() <= 599)
{
System.out.println("The final grade for the student is an F.");
}
else if (ComputeTestScore() <= 224 && ComputeTestScore() >= 210 && ComputeAssignmentScore() >= 600 && ComputeAssignmentScore() <= 779)
{
System.out.println("The final grade for the student is a D.");
}
else if (ComputeTestScore() <= 224 && ComputeTestScore() >= 210 && ComputeAssignmentScore() >= 780 && ComputeAssignmentScore() <= 959)
{
System.out.println("The final grade for the student is a C.");
}
else if (ComputeTestScore() <= 224 && ComputeTestScore() >= 210 && ComputeAssignmentScore() >= 900 && ComputeAssignmentScore() <= 1200)
{
System.out.println("The final grade for the student is a B.");
}
else if (ComputeTestScore() <= 239 && ComputeTestScore() >= 225 && ComputeAssignmentScore() <= 599)
{
System.out.println("The final grade for the student is an F.");
}
else if (ComputeTestScore() <= 239 && ComputeTestScore() >= 225 && ComputeAssignmentScore() >= 600 && ComputeAssignmentScore() <= 719)
{
System.out.println("The final grade for the student is a D.");
}
else if (ComputeTestScore() <= 239 && ComputeTestScore() >= 225 && ComputeAssignmentScore() >= 720 && ComputeAssignmentScore() <= 899)
{
System.out.println("The final grade for the student is a C.");
}
else if (ComputeTestScore() <= 239 && ComputeTestScore() >= 225 && ComputeAssignmentScore() >= 900 && ComputeAssignmentScore() <= 1139)
{
System.out.println("The final grade for the student is a B.");
}
else if (ComputeTestScore() <= 239 && ComputeTestScore() >= 225 && ComputeAssignmentScore() >= 1140 && ComputeAssignmentScore() <= 1200)
{
System.out.println("The final grade for the student is an A.");
}
else if (ComputeTestScore() >= 240 && ComputeTestScore() <= 254 && ComputeAssignmentScore() <= 599)
{
System.out.println("The final grade for the student is an F.");
}
else if (ComputeTestScore() >= 240 && ComputeTestScore() <= 254 && ComputeAssignmentScore() >= 600 && ComputeAssignmentScore() <= 659)
{
System.out.println("The final grade for the student is a D.");
}
else if (ComputeTestScore() >= 240 && ComputeTestScore() <= 254 && ComputeAssignmentScore() >= 660 && ComputeAssignmentScore() <= 839)
{
System.out.println("The final grade for the student is a C.");
}
else if (ComputeTestScore() >= 240 && ComputeTestScore() <= 254 && ComputeAssignmentScore() >= 840 && ComputeAssignmentScore() <= 1079)
{
System.out.println("The final grade for the student is a B.");
}
else if (ComputeTestScore() >= 240 && ComputeTestScore() <= 254 && ComputeAssignmentScore() >= 1080 && ComputeAssignmentScore() <= 1200)
{
System.out.println("The final grade for the student is an A.");
}
else if (ComputeTestScore() >= 255 && ComputeTestScore() <= 269 && ComputeAssignmentScore() <= 599)
{
System.out.println("The final grade for the student is an F.");
}
else if (ComputeTestScore() >= 255 && ComputeTestScore() <= 269 && ComputeAssignmentScore() >= 600 && ComputeAssignmentScore() <= 779)
{
System.out.println("The final grade for the student is a C.");
}
else if (ComputeTestScore() >= 255 && ComputeTestScore() <= 269 && ComputeAssignmentScore() >= 780 && ComputeAssignmentScore() <= 1019)
{
System.out.println("The final grade for the student is a B.");
}
else if (ComputeTestScore() >= 255 && ComputeTestScore() <= 269 && ComputeAssignmentScore() >= 1020 && ComputeAssignmentScore() <= 1200)
{
System.out.println("The final grade for the student is an A.");
}
else if (ComputeTestScore() >= 270 && ComputeTestScore() <= 284 && ComputeAssignmentScore() <= 599)
{
System.out.println("The final grade for the student is an F.");
}
else if (ComputeTestScore() >= 270 && ComputeTestScore() <= 284 && ComputeAssignmentScore() >= 600 && ComputeAssignmentScore() <= 779)
{
System.out.println("The final grade for the student is a C.");
}
else if (ComputeTestScore() >= 270 && ComputeTestScore() <= 284 && ComputeAssignmentScore() >= 780 && ComputeAssignmentScore() <= 899)
{
System.out.println("The final grade for the student is a B.");
}
else if (ComputeTestScore() >= 270 && ComputeTestScore() <= 284 && ComputeAssignmentScore() >= 900 && ComputeAssignmentScore() <= 1200)
{
System.out.println("The final grade for the student is an A.");
}
else if (ComputeTestScore() >= 285 && ComputeTestScore() <= 300 && ComputeAssignmentScore() <= 599)
{
System.out.println("The final grade for the student is an F.");
}
else if (ComputeTestScore() >= 285 && ComputeTestScore() <= 300 && ComputeAssignmentScore() >= 600 && ComputeAssignmentScore() <= 719)
{
System.out.println("The final grade for the student is a C.");
}
else if (ComputeTestScore() >= 285 && ComputeTestScore() <= 300 && ComputeAssignmentScore() >= 720 && ComputeAssignmentScore() <= 899)
{
System.out.println("The final grade for the student is a B.");
}
else if (ComputeTestScore() >= 285 && ComputeTestScore() <= 300 && ComputeAssignmentScore() >= 900 && ComputeAssignmentScore() <= 1200)
{
System.out.println("The final grade for the student is an A.");
}
System.out.println("                 ");
}
}```

4. Senior Member
Join Date
Oct 2010
Location
Germany
Posts
787
Rep Power
8
in each of your if-else statements you call the method ComputeTestScore several times :)

Java Code:
```if (ComputeTestScore() <= 149) {
System.out.println("The final grade for the student is an F.");
} else if (ComputeTestScore() <= 164 && ComputeTestScore() >= 150
&& ComputeAssignmentScore() <= 779) {```
maybe you should write int testscore = newInstance.ComputeTestScore(); in your main method an pass the "testscore" to the ComputeLetterGrade method!

5. Member
Join Date
Oct 2010
Posts
22
Rep Power
0
Okay, I completely understand what you're saying, but now something else is happening. I did this to all of the "ComputeTestScore()" in the ComputeLetterGrade method:

Java Code:
```if (testscore <= 149)
{
System.out.println("The final grade for the student is an F.");
}```
And did this to the main method:

Java Code:
```		public static void main (String [] args)
{
Scanner scanner = new Scanner(System.in);
System.out.println("Please enter the number of students.");
int studentNumber = 0;
studentNumber=scanner.nextInt();

for (int i=1; i<=studentNumber; i++)
{
System.out.println("Student " + i + ": ");
newInstance.ComputeAssignmentScore();
int testscore = newInstance.ComputeTestScore();
}
}```
But also, if what you're saying is true, then wouldn't I also have trouble with the ComputeAssignmentScore method, since that's also being called in the ComputeLetterGrade method?

6. Senior Member
Join Date
Oct 2010
Location
Germany
Posts
787
Rep Power
8
ok, you must inject the testscore to the method....

and

or you call the method ComputeTestScore() in ComputeLetterGrade and not in your main method, or .... or..... :)

EDIT:
Originally Posted by BariMutation
I also have trouble with the ComputeAssignmentScore method, since that's also being called in the ComputeLetterGrade method?
ahhhh yes, its the same....
Last edited by eRaaaa; 10-15-2010 at 12:40 AM.

7. Member
Join Date
Oct 2010
Posts
22
Rep Power
0
Originally Posted by eRaaaa
ahhhh yes, its the same....
Sorry, I don't understand that part... are you saying that now you don't get it, or that you're still right? lol

8. Member
Join Date
Oct 2010
Posts
22
Rep Power
0
SCRATCH THAT! I freaking love you dude, you got it working! But, one tiny problem - now it won't output the letter grade from the ComputeLetterGrade method. At the very end, it should say "The final grade for the student is an F." (or whatever they earned) Here's the entire program again...

Java Code:
```import java.util.*;
import java.util.Random;

{
public static void main (String [] args)
{
Scanner scanner = new Scanner(System.in);
System.out.println("Please enter the number of students.");
int studentNumber = 0;
studentNumber=scanner.nextInt();

for (int i=1; i<=studentNumber; i++)
{
System.out.println("Student " + i + ": ");
newInstance.ComputeAssignmentScore();
int testscore = newInstance.ComputeTestScore();
}
}
public int ComputeAssignmentScore()
{
Scanner scanner = new Scanner(System.in);

int finalAssignments = 0;
for (int j=1; j<=6; j++)
{
System.out.println("Assignment " + j + ": " + grade);
}		//End of Assignments Section

int finalAttendance = 0;
for (int k=1; k<=1; k++)
{
}	//End of Attendance Section

int finalLabs = 0;
for (int l=1; l<=15; l++)
{
System.out.println("Lab " + l + ": " + grade);
}	//End of Labs Section

int finalQuizzes = 0;
for (int q=1; q<=1; q++)
{
}

int OverallAssignments = 0;
OverallAssignments = finalLabs + finalAttendance + finalAssignments;//Finalizes the overall assignment section

return OverallAssignments;
}

public int ComputeTestScore()
{
int finalPAT = 0;
for (int n=1; n<=1; n++)
{
}		//End of PAT Section

int finalLOs = 0;
for (int m=1; m<=15; m++)
{
System.out.println("LO "+ m + ": " + grade);
}		//End of LOs Section

int finalMidterms = 0;
for (int o=1; o<=2; o++)
{
System.out.println("Midterm "+ o + ": " + grade);
}		//End of Midterms Section

int finalfE = 0;
for (int p=1; p<=1; p++)
{
}

int OverallTests = 0;
OverallTests = finalfE + finalMidterms + finalPAT + finalLOs;//End of FinalExam Section
return OverallTests;
}

{
if (testscore <= 149)
{
System.out.println("The final grade for the student is an F.");
}
else if (testscore <= 164 && testscore >= 150 && ComputeAssignmentScore() <= 779)
{
System.out.println("The final grade for the student is an F.");
}
else if (testscore <= 164 && testscore >= 150 && ComputeAssignmentScore() <=1079 && ComputeAssignmentScore() >= 780)
{
System.out.println("The final grade for the student is a D.");
}
else if (testscore <= 164 && testscore >= 150 && ComputeAssignmentScore() <= 1200 && ComputeAssignmentScore() >= 1080)
{
System.out.println("The final grade for the student is a C.");
}
else if (testscore <= 179 && testscore >= 165 && ComputeAssignmentScore() <= 719)
{
System.out.println("The final grade for the student is an F.");
}
else if (testscore <= 179 && testscore >= 165 && ComputeAssignmentScore() <= 959 && ComputeAssignmentScore() >= 720)
{
System.out.println("The final grade for the student is a D.");
}
else if (testscore <= 179 && testscore >= 165 && ComputeAssignmentScore() >= 960 && ComputeAssignmentScore() <= 1200)
{
System.out.println("The final grade for the student is a C.");
}
else if (testscore <= 194 && testscore >= 180 && ComputeAssignmentScore() <= 659)
{
System.out.println("The final grade for the student is an F.");
}
else if (testscore <= 194 && testscore >= 180 && ComputeAssignmentScore() <=899 && ComputeAssignmentScore() >= 660)
{
System.out.println("The final grade for the student is a D.");
}
else if (testscore <= 194 && testscore >= 180 && ComputeAssignmentScore() <= 1139 && ComputeAssignmentScore() >= 900)
{
System.out.println("The final grade for the student is a C.");
}
else if (testscore <= 194 && testscore >= 180 && ComputeAssignmentScore() <= 1200 && ComputeAssignmentScore() >= 1140)
{
System.out.println("The final grade for the student is a B.");
}
else if (testscore <= 209 && testscore >= 195 && ComputeAssignmentScore() <= 659)
{
System.out.println("The final grade for the student is an F.");
}
else if (testscore <= 209 && testscore >= 195 && ComputeAssignmentScore() >= 660 && ComputeAssignmentScore() <= 839)
{
System.out.println("The final grade for the student is a D.");
}
else if (testscore <= 209 && testscore >= 195 && ComputeAssignmentScore() >= 840 && ComputeAssignmentScore() <= 1079)
{
System.out.println("The final grade for the student is a C.");
}
else if (testscore <= 209 && testscore >= 195 && ComputeAssignmentScore() >= 1080 && ComputeAssignmentScore() <= 1200)
{
System.out.println("The final grade for the student is a B.");
}
else if (testscore <= 224 && testscore >= 210 && ComputeAssignmentScore() <= 599)
{
System.out.println("The final grade for the student is an F.");
}
else if (testscore <= 224 && testscore >= 210 && ComputeAssignmentScore() >= 600 && ComputeAssignmentScore() <= 779)
{
System.out.println("The final grade for the student is a D.");
}
else if (testscore <= 224 && testscore >= 210 && ComputeAssignmentScore() >= 780 && ComputeAssignmentScore() <= 959)
{
System.out.println("The final grade for the student is a C.");
}
else if (testscore <= 224 && testscore >= 210 && ComputeAssignmentScore() >= 900 && ComputeAssignmentScore() <= 1200)
{
System.out.println("The final grade for the student is a B.");
}
else if (testscore <= 239 && testscore >= 225 && ComputeAssignmentScore() <= 599)
{
System.out.println("The final grade for the student is an F.");
}
else if (testscore <= 239 && testscore >= 225 && ComputeAssignmentScore() >= 600 && ComputeAssignmentScore() <= 719)
{
System.out.println("The final grade for the student is a D.");
}
else if (testscore <= 239 && testscore >= 225 && ComputeAssignmentScore() >= 720 && ComputeAssignmentScore() <= 899)
{
System.out.println("The final grade for the student is a C.");
}
else if (testscore <= 239 && testscore >= 225 && ComputeAssignmentScore() >= 900 && ComputeAssignmentScore() <= 1139)
{
System.out.println("The final grade for the student is a B.");
}
else if (testscore <= 239 && testscore >= 225 && ComputeAssignmentScore() >= 1140 && ComputeAssignmentScore() <= 1200)
{
System.out.println("The final grade for the student is an A.");
}
else if (testscore >= 240 && testscore <= 254 && ComputeAssignmentScore() <= 599)
{
System.out.println("The final grade for the student is an F.");
}
else if (testscore >= 240 && testscore <= 254 && ComputeAssignmentScore() >= 600 && ComputeAssignmentScore() <= 659)
{
System.out.println("The final grade for the student is a D.");
}
else if (testscore >= 240 && testscore <= 254 && ComputeAssignmentScore() >= 660 && ComputeAssignmentScore() <= 839)
{
System.out.println("The final grade for the student is a C.");
}
else if (testscore >= 240 && testscore <= 254 && ComputeAssignmentScore() >= 840 && ComputeAssignmentScore() <= 1079)
{
System.out.println("The final grade for the student is a B.");
}
else if (testscore >= 240 && testscore <= 254 && ComputeAssignmentScore() >= 1080 && ComputeAssignmentScore() <= 1200)
{
System.out.println("The final grade for the student is an A.");
}
else if (testscore >= 255 && testscore <= 269 && ComputeAssignmentScore() <= 599)
{
System.out.println("The final grade for the student is an F.");
}
else if (testscore >= 255 && testscore <= 269 && ComputeAssignmentScore() >= 600 && ComputeAssignmentScore() <= 779)
{
System.out.println("The final grade for the student is a C.");
}
else if (testscore >= 255 && testscore <= 269 && ComputeAssignmentScore() >= 780 && ComputeAssignmentScore() <= 1019)
{
System.out.println("The final grade for the student is a B.");
}
else if (testscore >= 255 && testscore <= 269 && ComputeAssignmentScore() >= 1020 && ComputeAssignmentScore() <= 1200)
{
System.out.println("The final grade for the student is an A.");
}
else if (testscore >= 270 && testscore <= 284 && ComputeAssignmentScore() <= 599)
{
System.out.println("The final grade for the student is an F.");
}
else if (testscore >= 270 && testscore <= 284 && ComputeAssignmentScore() >= 600 && ComputeAssignmentScore() <= 779)
{
System.out.println("The final grade for the student is a C.");
}
else if (testscore >= 270 && testscore <= 284 && ComputeAssignmentScore() >= 780 && ComputeAssignmentScore() <= 899)
{
System.out.println("The final grade for the student is a B.");
}
else if (testscore >= 270 && testscore <= 284 && ComputeAssignmentScore() >= 900 && ComputeAssignmentScore() <= 1200)
{
System.out.println("The final grade for the student is an A.");
}
else if (testscore >= 285 && testscore <= 300 && ComputeAssignmentScore() <= 599)
{
System.out.println("The final grade for the student is an F.");
}
else if (testscore >= 285 && testscore <= 300 && ComputeAssignmentScore() >= 600 && ComputeAssignmentScore() <= 719)
{
System.out.println("The final grade for the student is a C.");
}
else if (testscore >= 285 && testscore <= 300 && ComputeAssignmentScore() >= 720 && ComputeAssignmentScore() <= 899)
{
System.out.println("The final grade for the student is a B.");
}
else if (testscore >= 285 && testscore <= 300 && ComputeAssignmentScore() >= 900 && ComputeAssignmentScore() <= 1200)
{
System.out.println("The final grade for the student is an A.");
}
System.out.println("                 ");
}
}```

9. Senior Member
Join Date
Oct 2010
Location
Germany
Posts
787
Rep Power
8
hmm..check your conditions and the value of testscore..and whats about the ComputeAssignmentScore() ? why didnt you change it in the ComputeLetterGrade method too? :confused:

10. Member
Join Date
Oct 2010
Posts
22
Rep Power
0
I'm... not sure why I didn't change it lol But bear with me on this, the professor hasn't taught us any of this, so I'm really oblivious as to what I'm doing :( Here's where I'm at now... it obviously isn't working still.

Java Code:
```import java.util.*;
import java.util.Random;

{
public static void main (String [] args)
{
Scanner scanner = new Scanner(System.in);
System.out.println("Please enter the number of students.");
int studentNumber = 0;
studentNumber=scanner.nextInt();

for (int i=1; i<=studentNumber; i++)
{
System.out.println("Student " + i + ": ");
newInstance.ComputeAssignmentScore();
int assignmentscore = newInstance.ComputeAssignmentScore();
int testscore = newInstance.ComputeTestScore();
}
}
public int ComputeAssignmentScore()
{
Scanner scanner = new Scanner(System.in);

int finalAssignments = 0;
for (int j=1; j<=6; j++)
{
System.out.println("Assignment " + j + ": " + grade);
}		//End of Assignments Section

int finalAttendance = 0;
for (int k=1; k<=1; k++)
{
}	//End of Attendance Section

int finalLabs = 0;
for (int l=1; l<=15; l++)
{
System.out.println("Lab " + l + ": " + grade);
}	//End of Labs Section

int finalQuizzes = 0;
for (int q=1; q<=1; q++)
{
}

int OverallAssignments = 0;
OverallAssignments = finalLabs + finalAttendance + finalAssignments;//Finalizes the overall assignment section

return OverallAssignments;
}

public int ComputeTestScore()
{
int finalPAT = 0;
for (int n=1; n<=1; n++)
{
}		//End of PAT Section

int finalLOs = 0;
for (int m=1; m<=15; m++)
{
System.out.println("LO "+ m + ": " + grade);
}		//End of LOs Section

int finalMidterms = 0;
for (int o=1; o<=2; o++)
{
System.out.println("Midterm "+ o + ": " + grade);
}		//End of Midterms Section

int finalfE = 0;
for (int p=1; p<=1; p++)
{
}

int OverallTests = 0;
OverallTests = finalfE + finalMidterms + finalPAT + finalLOs;//End of FinalExam Section
return OverallTests;
}

public void ComputeLetterGrade(int testscore; int assignmentscore)
{
if (testscore <= 149)
{
System.out.println("The final grade for the student is an F.");
}
else if (testscore <= 164 && testscore >= 150 && assignmentscore <= 779)
{
System.out.println("The final grade for the student is an F.");
}
else if (testscore <= 164 && testscore >= 150 && assignmentscore <=1079 && assignmentscore >= 780)
{
System.out.println("The final grade for the student is a D.");
}
else if (testscore <= 164 && testscore >= 150 && assignmentscore <= 1200 && assignmentscore >= 1080)
{
System.out.println("The final grade for the student is a C.");
}
else if (testscore <= 179 && testscore >= 165 && assignmentscore <= 719)
{
System.out.println("The final grade for the student is an F.");
}
else if (testscore <= 179 && testscore >= 165 && assignmentscore <= 959 && assignmentscore >= 720)
{
System.out.println("The final grade for the student is a D.");
}
else if (testscore <= 179 && testscore >= 165 && assignmentscore >= 960 && assignmentscore <= 1200)
{
System.out.println("The final grade for the student is a C.");
}
else if (testscore <= 194 && testscore >= 180 && assignmentscore <= 659)
{
System.out.println("The final grade for the student is an F.");
}
else if (testscore <= 194 && testscore >= 180 && assignmentscore <=899 && assignmentscore >= 660)
{
System.out.println("The final grade for the student is a D.");
}
else if (testscore <= 194 && testscore >= 180 && assignmentscore <= 1139 && assignmentscore >= 900)
{
System.out.println("The final grade for the student is a C.");
}
else if (testscore <= 194 && testscore >= 180 && assignmentscore <= 1200 && assignmentscore >= 1140)
{
System.out.println("The final grade for the student is a B.");
}
else if (testscore <= 209 && testscore >= 195 && assignmentscore <= 659)
{
System.out.println("The final grade for the student is an F.");
}
else if (testscore <= 209 && testscore >= 195 && assignmentscore >= 660 && assignmentscore <= 839)
{
System.out.println("The final grade for the student is a D.");
}
else if (testscore <= 209 && testscore >= 195 && assignmentscore >= 840 && assignmentscore <= 1079)
{
System.out.println("The final grade for the student is a C.");
}
else if (testscore <= 209 && testscore >= 195 && assignmentscore >= 1080 && assignmentscore <= 1200)
{
System.out.println("The final grade for the student is a B.");
}
else if (testscore <= 224 && testscore >= 210 && assignmentscore <= 599)
{
System.out.println("The final grade for the student is an F.");
}
else if (testscore <= 224 && testscore >= 210 && assignmentscore >= 600 && assignmentscore <= 779)
{
System.out.println("The final grade for the student is a D.");
}
else if (testscore <= 224 && testscore >= 210 && assignmentscore >= 780 && assignmentscore <= 959)
{
System.out.println("The final grade for the student is a C.");
}
else if (testscore <= 224 && testscore >= 210 && assignmentscore >= 900 && assignmentscore <= 1200)
{
System.out.println("The final grade for the student is a B.");
}
else if (testscore <= 239 && testscore >= 225 && assignmentscore <= 599)
{
System.out.println("The final grade for the student is an F.");
}
else if (testscore <= 239 && testscore >= 225 && assignmentscore >= 600 && assignmentscore <= 719)
{
System.out.println("The final grade for the student is a D.");
}
else if (testscore <= 239 && testscore >= 225 && assignmentscore >= 720 && assignmentscore <= 899)
{
System.out.println("The final grade for the student is a C.");
}
else if (testscore <= 239 && testscore >= 225 && assignmentscore >= 900 && assignmentscore <= 1139)
{
System.out.println("The final grade for the student is a B.");
}
else if (testscore <= 239 && testscore >= 225 && assignmentscore >= 1140 && assignmentscore <= 1200)
{
System.out.println("The final grade for the student is an A.");
}
else if (testscore >= 240 && testscore <= 254 && assignmentscore <= 599)
{
System.out.println("The final grade for the student is an F.");
}
else if (testscore >= 240 && testscore <= 254 && assignmentscore >= 600 && assignmentscore <= 659)
{
System.out.println("The final grade for the student is a D.");
}
else if (testscore >= 240 && testscore <= 254 && assignmentscore >= 660 && assignmentscore <= 839)
{
System.out.println("The final grade for the student is a C.");
}
else if (testscore >= 240 && testscore <= 254 && assignmentscore >= 840 && assignmentscore <= 1079)
{
System.out.println("The final grade for the student is a B.");
}
else if (testscore >= 240 && testscore <= 254 && assignmentscore >= 1080 && assignmentscore <= 1200)
{
System.out.println("The final grade for the student is an A.");
}
else if (testscore >= 255 && testscore <= 269 && assignmentscore <= 599)
{
System.out.println("The final grade for the student is an F.");
}
else if (testscore >= 255 && testscore <= 269 && assignmentscore >= 600 && assignmentscore <= 779)
{
System.out.println("The final grade for the student is a C.");
}
else if (testscore >= 255 && testscore <= 269 && assignmentscore >= 780 && assignmentscore <= 1019)
{
System.out.println("The final grade for the student is a B.");
}
else if (testscore >= 255 && testscore <= 269 && assignmentscore >= 1020 && assignmentscore <= 1200)
{
System.out.println("The final grade for the student is an A.");
}
else if (testscore >= 270 && testscore <= 284 && assignmentscore <= 599)
{
System.out.println("The final grade for the student is an F.");
}
else if (testscore >= 270 && testscore <= 284 && assignmentscore >= 600 && assignmentscore <= 779)
{
System.out.println("The final grade for the student is a C.");
}
else if (testscore >= 270 && testscore <= 284 && assignmentscore >= 780 && assignmentscore <= 899)
{
System.out.println("The final grade for the student is a B.");
}
else if (testscore >= 270 && testscore <= 284 && assignmentscore >= 900 && assignmentscore <= 1200)
{
System.out.println("The final grade for the student is an A.");
}
else if (testscore >= 285 && testscore <= 300 && assignmentscore <= 599)
{
System.out.println("The final grade for the student is an F.");
}
else if (testscore >= 285 && testscore <= 300 && assignmentscore >= 600 && assignmentscore <= 719)
{
System.out.println("The final grade for the student is a C.");
}
else if (testscore >= 285 && testscore <= 300 && assignmentscore >= 720 && assignmentscore <= 899)
{
System.out.println("The final grade for the student is a B.");
}
else if (testscore >= 285 && testscore <= 300 && assignmentscore >= 900 && assignmentscore <= 1200)
{
System.out.println("The final grade for the student is an A.");
}
System.out.println("                 ");
}
}```

11. Senior Member
Join Date
Oct 2010
Location
Germany
Posts
787
Rep Power
8
:eek:

---->

and

public void ComputeLetterGrade(int testscore; int assignmentscore)

---->