Question: Exercise 1: Arrays of Primitives Declare a reference variable for an array of doubles. Name the array prices. Instantiate the prices array to hold 50

Exercise 1: Arrays of Primitives

  1. Declare a reference variable for an array of doubles. Name the array prices.
  2. Instantiate the prices array to hold 50 doubles.
  3. Set the third array element of prices to 13.99. REMEMBER: Array indexing starts at 0.
  4. Write a for loop to count the number of values in the prices array that are greater than 10.

Exercise 2: Comparing Objects

Write an equals method for the Car class given here. Two Cars are equal if their Vehicle Identification Numbers (VIN) are the same. HINT: The String class has an equals method that can be called from the Car class equalsmethod.

Exercise 3: UML diagrams

Draw the UML diagram for the Car class from Exercise 2 after including the equals method.

Exercise 4: Arrays of Objects

  1. Declare and instantiate an array of 40 cars using the Car class. Name the array dealerCars.
  2. Write Java statements to add three cars to the dealerCars array.
  3. Make a hole at the beginning of the dealerCars array by moving the cars in the array up by one position.
  4. Add another car to the beginning of the array.
  5. Write a for loop to display all the cars in the dealerCars array. Add any necessary methods to the Car class.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!