Java while loops

Quiz
•
Computers
•
10th - 12th Grade
•
Hard
Claire Firman
Used 32+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 5 pts
Input the number of cousins which an unknown quantity of people have, stopping when a negative number is input. Work out the average and the maximum number of cousins. The rest of this quiz will analyse and produce a solution to this problem.
Should you use a while loop or a for loop?
while loop
for loop
Answer explanation
It's for an unknown number of people so that's the right answer!
2.
MULTIPLE CHOICE QUESTION
30 sec • 5 pts
Doing a SITC analysis, what should you SELECT as the variable for the while loop?
(Problem again:
Input the number of cousins which an unknown quantity of people have, stopping when a negative number is input. Work out the average and the maximum number of cousins.)
number of cousins
maximum number of cousins
average number of cousins
height of the cousins
Answer explanation
We are inputting the number of cousins for many people so that is the right answer.
3.
MULTIPLE CHOICE QUESTION
30 sec • 5 pts
How will you initialise the number of cousins?
numCousins = 0
Input numCousins
Output numCousins
numCousins = 10
4.
MULTIPLE CHOICE QUESTION
30 sec • 5 pts
What will you test in your while loop?
numCousins >= 0
numCousins < 0
numCousins == 0
5.
FILL IN THE BLANK QUESTION
1 min • 5 pts
To CHANGE the variable, we will ___ numCousins again
6.
MULTIPLE CHOICE QUESTION
30 sec • 5 pts
Is this code correct?
int numCousins;
numCousins = Double.parseDouble(JOptionPane.showInputDialog("Input number of cousins (-ve to stop)"));
Yes
All good to declare and input an int.
No
It should be Integer.parseInt
No
It should be Int.parseInt
No
It should say:
integer numCousins;
7.
MULTIPLE SELECT QUESTION
45 sec • 5 pts
To find the maximum, you need to add this code:
int max;
max = 0;
if (numCousins > max)
{
max = numCousins;
}
max = -10;
Create a free account and access millions of resources
Similar Resources on Wayground
13 questions
APCSA Unit 3 Review

Quiz
•
9th - 12th Grade
6 questions
Arduino Code Revision

Quiz
•
11th Grade
10 questions
Python списки

Quiz
•
10th Grade
10 questions
2.2.1 (d) Variables

Quiz
•
12th Grade
15 questions
CP M4 Repetition & Loops

Quiz
•
9th - 12th Grade
10 questions
Quiz 16 - Arrays and Loops

Quiz
•
11th Grade
14 questions
Python - MP2 Test

Quiz
•
10th Grade
10 questions
C_หน่วย 3

Quiz
•
12th Grade
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
9/11 Experience and Reflections

Interactive video
•
10th - 12th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
9 questions
Tips & Tricks

Lesson
•
6th - 8th Grade
Discover more resources for Computers
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
10 questions
1.2 OSI & TCP IP Models Quiz

Quiz
•
10th Grade
20 questions
Digital Citizenship

Quiz
•
8th - 12th Grade
35 questions
Computer Baseline Examination 2025-26

Quiz
•
9th - 12th Grade
13 questions
Problem Solving Process

Quiz
•
9th - 12th Grade
20 questions
Hardware vs. Software Quiz

Quiz
•
7th - 10th Grade
10 questions
Understanding Algorithms with Pseudocode and Flowcharts

Interactive video
•
9th - 12th Grade
19 questions
AP CSP Unit 1 Review (code.org)

Quiz
•
10th - 12th Grade