Verityprep
Question Bank · Unit 2

AP® Computer Science A Selection and Iteration FRQ

Work through AP Computer Science A free-response questions on Selection and Iteration, then check each answer against a worked solution.

Free · no sign-up Open questions need no account. Sign up or log in to open the rest.

Questions 21–30 of 48
  1. 21
  2. 22
  3. 23
  4. 24
  5. 25
  6. 26
  7. 27
  8. 28
  9. 29
  10. 30

Question 21

Free response Boolean Expressions
Given three ints, a b c, return true if two or more of them have the same rightmost digit. The ints are non-negative. Note: the % "mod" operator computes the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 22

Free response Boolean Expressions
Given three ints, a b c, return true if one of them is 10 or more less than one of the others. lessBy10(1, 7, 11) → true…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 23

Free response Boolean Expressions
Return the sum of two 6-sided dice rolls, each in the range 1..6. However, if noDoubles is true, if the two dice show the same value, increment one die to the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 24

Free response Boolean Expressions
Given two int values, return whichever value is larger. However if the two values have the same remainder when divided by 5, then the return the smaller value.…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 25

Free response Boolean Expressions
You have a red lottery ticket showing ints a, b, and c, each of which is 0, 1, or 2. If they are all the value 2, the result is 10. Otherwise if they are all…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 26

Free response Boolean Expressions
You have a green lottery ticket, with ints a, b, and c on it. If the numbers are all different from each other, the result is 0. If all of the numbers are the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 27

Free response Boolean Expressions
You have a blue lottery ticket, with ints a, b, and c on it. This makes three pairs, which we'll call ab, bc, and ac. Consider the sum of the numbers in each…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 28

Free response Boolean Expressions
Given two ints, each in the range 10..99, return true if there is a digit that appears in both numbers, such as the 2 in 12 and 23. (Note: division, e.g. n/10,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 29

Free response Boolean Expressions
Given 2 non-negative ints, a and b, return their sum, so long as the sum has the same number of digits as a. If the sum has more digits than a, just return a…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 30

Free response Boolean Expressions
We want to make a row of bricks that is goal inches long. We have a number of small bricks (1 inch each) and big bricks (5 inches each). Return true if it is…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 21 of 48
Page 3 of 5