filmov
tv
Java Practice It || 5.29 assertions3 || assertions, method with return, if statement, while loop
Показать описание
Problem:
Question:
For each of the five points labeled by comments, identify each of the assertions in the table below as either being always true, never true, or sometimes true / sometimes false.
public static int mystery(Scanner console) {
int prev = 0;
int count = 0;
// Point A
while (next != 0) {
// Point B
if (next == prev) {
// Point C
count++;
}
prev = next;
// Point D
}
// Point E
return count;
}
Fill in each box of the the table below with ALWAYS, NEVER or SOMETIMES.
Question:
For each of the five points labeled by comments, identify each of the assertions in the table below as either being always true, never true, or sometimes true / sometimes false.
public static int mystery(Scanner console) {
int prev = 0;
int count = 0;
// Point A
while (next != 0) {
// Point B
if (next == prev) {
// Point C
count++;
}
prev = next;
// Point D
}
// Point E
return count;
}
Fill in each box of the the table below with ALWAYS, NEVER or SOMETIMES.