Unit 1 Lesson 3 Homework

Part A: Core Understanding

  1. Identify the best AP CSA data type for each value.
    a. Number of students    b. Ticket price    c. Whether a game is finished



  1. Determine whether each Java variable name is valid. Explain any invalid name.
    a. finalScore    b. 4thQuarter    c. double    d. player_2



Part B: Read and Trace

  1. Determine the exact output.
int first = 12;
int second = first;
first = 30;

System.out.println(second);



  1. Determine the exact output.
int tickets = 7;
int bonus = 3;
tickets = tickets + bonus * 2;

System.out.println(tickets);



  1. Determine the value printed by each statement.
    a. 13 / 4    b. 13 / 4.0    c. 13.0 / 4



  1. Choose the Scanner method for each input.
    a. A whole number    b. A decimal number



Part C: Find and Fix

  1. Correct the code so score has a value before use.
int score;
int doubled = score * 2;



  1. Correct the declaration without changing the stored value.
int distance = 12.5;



Part D: Write Code

  1. Declare all three values with meaningful camelCase names. A complete main method is not required.
  • 18 books
  • a temperature of 21.5 degrees
  • whether the library is open




  1. Declare the constant MAX_PLAYERS with value 6.