Java Language Practice Assignments

Submission Instructions

Submit each of the following practice assignments at codePost.io. To register for a free codePost account, please follow these instructions.
Watch this short video for a demonstration of submitting an assignment and reviewing the results:
YouTube video: codePost: Submission and Checking Results Thumbnail
Note, currently, feedback is not visible in Safari.

Practice Assignments

Java Variables

In Java, we always specify the data type when we're declaring a variable. The syntax is:
dataType  variableName
For this practice assignment, you get to write a simple class named JavaVariables. Declare a main method in that class. In that main method, have it do the following in the the order specified:
  1. Declare an int variable named nine09 and initialize it to your 909-number
  2. Declare a String variable named subject and initialize it to "CPSC"
  3. Declare an int variable named courseNumber and initialize it to 1302
  4. Declare a char variable named courseSuffix and initialize it to 'K' (notice that in Java, Strings use two double quotes ("..."), whereas chars use two single quotes ('.'))
  5. Declare a boolean variable named isOnline (but do not initialize when declaring it)
  6. Declare a double variable named points (but do not initialize when declaring it)
  7. Assign isOnline to reflect if you are taking this course online or in-person (do this on a different line of code than the declaration)
  8. Assign points to be 97.5 (do this on a different line of code than the declaration)
  9. Display the value stored in the nine09 variable on its own line. For example, something like:
    909123456
  10. Display the following output, using the variables above:
    CPSC 1302K (online: true): 97.5 points
    or
    CPSC 1302K (online: false): 97.5 points
Note, the text that is underlined in the example output above is required by the test cases.