Declare and Initialize Variables Based on Descriptions
For the data descriptions listed below, first determine whether they are primitive data or object data. If they are primitive data, which of the 8 data types would be best to use to represent the data? The 8 primitive data types are: byte
, short
, int
, long
, float
, double
, char
, boolean
. If it is primitive data, what would the initial value might be? Try your statements in the Java playground. Be sure to toggle the console to Detailed Output to see what is happening in the program.
- A student's age
- The grade a student is in
- Student's GPA
- A Game Score
- Whether you want to continue the game or not
- A middle initial
- The color of a block
- Whether someone is married or not
- Price of a menu item
- The number of degrees to rotate a robot to the right
- The date for the first day of school
- The number of minutes until your order is ready
- The name of the school
- Price per unit for fruit
- Your street address
- A customer's phone number
- A meteorite landing that includes the name of the meteorite, the date it landed, its mass, and landing location
- A spinner that has 4 equal sections each with a different color
- A card in a deck of 52 cards
- The response from an invited guest for whether they are attending a party or not
Making Modifications to Variable Declarations
For each of the following variable declarations, make modification so that the code works as intended.
Declare and initialize a variable to store whether a person is considered an adult or not.
Declare and initialize a variable to store the average weight of an apple.
Declare and initialize a variable to store a letter grade.
Declare and initialize a variable to the capacity of a buss.