Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!

del barton
Greenhorn
Posts: 1
{
public static void main(String[] args )
{
int numberofstudents,score;
double next;

do
{
System.out.println("Enter scores for all students");
System.out.println("Enter a negative numger after");
System.out.println("You have entered all the scores.");

numberofstudents = 0;
score = 0;
while (next >=0)
{
numberofstudents++;
}
if (numberofstudents > 0)
System.out.println("Total number of grades " + (numberofstudents));

{

if (score >= 90){
numberofstudents++;}
else if (score >= 80){
numberofstudents++;}
else if (score >= 70){
numberofstudents++;}
else if (score >= 60){
numberofstudents++;}
else if (score < 60){
numberofstudents++;}
}
System.out.println("Number of A's = " + (numberofstudents++));
System.out.println("Number of B's = " + (numberofstudents++));
System.out.println("Number of C's = "+ (numberofstudents++));
System.out.println("Number of D's = "+ (numberofstudents++));
System.out.println("Number of F's = "+ (numberofstudents++));

System.out.println("Want to score another exam?");
System.out.println("Enter y for yes or n for no.");
}
}

will not calculate the right number of letter grades
what am I doing wrong ?

Elouise Kivineva
Ranch Hand
Posts: 154
"code" and "/code" (replace my double quote marks w/ square brackets)
markers to get the proper formatting.

First problem I see in your code is that you initialize grade as 0 and never read into it (from input) any other value.
When you read a grade, you count that as one more student. You never actually record the grade itself.

Now write down the names of all your variables on a sheet of scratch paper. These are column headers.
Run through your program using the test input and write down under each
variable (in its column) the values that variable takes on as you run through the program. If it helps you can write down the changes taking place row by row (number the rows in your code and below your columns - graph papaer is good for this).

Are things working the way you planned?
[ November 20, 2004: Message edited by: Elouise Kivineva ]

Max Labaio-Burreal
Greenhorn
Posts: 3
Hey sorry im a newbie, i havent as much knowledge as others in the site, well i just wanted to say when you install your JDK doesnt it give you info if there are errors on your site?
also can i get help like tutorials from someone here?

Layne Lund
Ranch Hand
Posts: 3061
Originally posted by Max Labaio-Burreal:
Hey sorry im a newbie, i havent as much knowledge as others in the site, well i just wanted to say when you install your JDK doesnt it give you info if there are errors on your site?
also can i get help like tutorials from someone here?

If this is a new question, you should click "Post a New Topic" to start your own thread.

Layne

Layne Lund
Ranch Hand
Posts: 3061
Originally posted by del barton:

... will not calculate the right number of letter grades
what am I doing wrong ?