Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

4th Edition

0619064625, 978-0619064624

More Books

Students also viewed these Databases questions