Question: QUESTION 3 [15 Marks] The class Car has the following I Three instance variables. One is of type string to store the name of the

 QUESTION 3 [15 Marks] The class Car has the following I
Three instance variables. One is of type string to store the name

QUESTION 3 [15 Marks] The class Car has the following I Three instance variables. One is of type string to store the name of the car. The second variable is of type integer to store the year model. The third variable is of type double to store the price of the car Three set methods to set the car name, year model and price. Three get methods to return the values of the instance variables. toString method to return the values of the instance variables as a string. . Default parameter to set the values of the instance variables to the default values. Parameterized constructor that sets the values of the instance variables to the values given in the parameter list, 1) Write a Java code that defines the class Car described above. [10 Marks] 2) Write a Java program to create and manipulate an object of the class Car. Ask the user to enter the values of the instance variables to create the object. Then, test various operations of the class. [5 Marks] QUESTION 1 10 Marks] Write a java code to: 1) Declare and instantiate an array called age of type integer. The size of the array should be 5. Then, initialize each element in the array as follows. If the index of the element is even, then set the value of the element to be equal to its index However, if the index is odd, then set the value of the element to be equal to the double of its index value. Use loop for initializing the array (5 Marks) 2) Define a double variable (choose variable name). Then, read its value from the user. Use try-catch concepts to check the validity of the user input. [s Marks]

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!