Top Posters
Since Sunday
5
a
5
k
5
c
5
B
5
l
5
C
4
s
4
a
4
t
4
i
4
r
4
New Topic  
Oughto Oughto
wrote...
Posts: 742
Rep: 1 0
7 years ago
Look at the following code:

Scanner keyboard = new Scanner(System.in);
int studentGrade = 0;
int totalOfStudentGrades = 0;
while(studentGrade != -1)
{
   System.out.println("Enter student grade: :");
   studentGrade = keyboard.nextInt();
   totalOfStudentGrades += studentGrade;
 }

In the loop header: while(studentGrade != -1), what is the purpose of "-1"?
A) It is a sentinel.
B) It tells the program to give the student a grade of -1, if he does not have any grades.
C) It initializes the count of the number of grades.
D) If the grade is not -1, the while statement will not be executed.
Textbook 
Starting Out with Java: Early Objects

Starting Out with Java: Early Objects


Edition: 4th
Author:
Read 217 times
3 Replies
Replies
Answer verified by a subject expert
ToothyToothy
wrote...
Top Poster
Posts: 744
Rep: 4 0
7 years ago
Sign in or Sign up in seconds to unlock everything for free
More solutions for this book are available here
1

Related Topics

Oughto Author
wrote...
7 years ago
good riddance to this computer class, never want to code again lol
wrote...
7 years ago
I'm happy to help
New Topic      
Explore
Post your homework questions and get free online help from our incredible volunteers
  1418 People Browsing
Related Images
  
 13178
  
 448
  
 778
Your Opinion