AP Computer Science A Quiz
19 questions · no time limit
0:00
SELECTION AND ITERATION
Question 1 of 19
No time limit
Current
Answered
Flagged
Not seen
You are writing a grade-processing program for a teacher. The program reads n integer scores (0–100) into an array and then prints each student's letter grade and the class average. Letter grades are assigned using selection: if score >= 90 then 'A', else if >= 80 then 'B', else if >= 70 then 'C', else if >= 60 then 'D', else 'F'. The program must use iteration to (1) read scores, (2) compute the sum, and (3) print results. Input format: first line n, second line contains n scores separated by spaces. Output format: one line per student in the form "score: letter", then a final line "avg: X" where X is the average as a double with one decimal. Constraints: 0≤n≤30; each score is 0–100. Edge cases: if n=0, print only "avg: 0.0".
Based on the task requirements, which condition will correctly exit the input-reading loop?
int i = 0;
// read n scores into scores[]
while (/* condition */) {
scores[i] = in.nextInt();
i++;
} YOUR PROGRESS
19
QUESTIONS
Ready when you are
Answer in any order. Your progress shows here as you go.
QUESTIONS
KEYBOARD
Pick an answer ABCD
Next question ↵→
Previous ←
Flag for review F
Answers save as you go · flagged questions come back at the end