I need to print out the scores and the grades when entered and i do not know how to print the scanner. im sure i am probably missing other things as well.

import java.util.Scanner;

public class Scores
{

  public static void main(String[] args)
{

	int count;
	int score;
	int total;

	Scanner input = new Scanner ( System.in );
	count =0;
	total =0;

	score = input.nextInt();

	while (score != -1)

	{
		count++;
		total = total+ score;
		score = input.nextInt();
    }


	System.out.printf("%s%d%s\n", "There are ",count, " student(s) in the class");
	System.out.printf("%s%d%s\n", "The total of their scores = ",total, " points");
    System.out.println(count);
	System.out.println(total);



	  System.out.print("Enter Score ==>");
			score=input.nextInt();
			count++;


		{
			if (score >= 90)
				System.out.print("A");
			  else
			  	if (score >=80)
			  	System.out.print("B");
			  else
			  	if (score >= 70)
			  	System.out.print("C");
			  else
			  	if (score >=60)
			  	System.out.print("D");
			  else
			  	if (score >= 59)
			  	System.out.print("F");
				System.out.print("score");
		}


}
}

Recommended Answers

All 4 Replies

I need to print out the scores and the grades when entered and i do not know how to print the scanner. im sure i am probably missing other things as well.

print the scanner?? or print the variables you used scanner at?? please make it more clear

also

System.out.printf("%s%d%s\n", "There are ",count, " student(s) in the class");
System.out.printf("%s%d%s\n", "The total of their scores = ",total,"points");

I'm not sure if this is the right way of doing this... I think it's more like this.

System.out.println("There are " + count + " student(s) in the class");
System.out.println("The total of their scores = " + total + "points");

print the variables and the corresponding grade.

I already showed the right way of printing it out in my first post

System.out.println("There are " + count + " student(s) in the class");
System.out.println("The total of their scores = " + total + "points");

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.