subject

Write a class named car that represents a car. your car class should have the followning: 1. instance variablesi. make and model of the carii. color of the cariii. the car's priceiv. the car's mileage (total miles traveled, not miles per gallon)2. two overloaded constructorsi. a constructor that takes no parameters. this constructor should set the mileage to 0 and set some default values (use whatever you want ) for the make, model, color and price. ii. a constructor that allows you to set values for the make, model, color and price. this constructor should also set the mileage to 0.3. methodspublic void setprice(double p)this should update the instance variable for price with the specified value. public void paint(string c)this should "paint " the car by changing the instance variable for color with the specified value. public void displaycarinfo()this should display all available information on the car, including its make, model, coor, price, and mileage. public void travel(double distance)this should display a message saying that the car is traveling for the specified distance. this method should also increase the value of the mileage attribute accordingly. after the car class, write a separate client program containing a main method that does the following actions: 1. create two new car objects: a black porsche cayman s with a price of $ 63,800, and a blue nissan leaf with a price of $ 28,800.2. display information for each object by calling its displaycarinfo method.3. paint the cayman purple and the leaf green.4. make the cayman travel 12,000 miles and the leaf 8,000 miles.5. change the price of the cayman to $50,000 and the price of the leaf to $ 24,500.6. call displaycarinfo on each object again to see how the instance variables have changed.

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 11:30, lindalu
Hassan is writing his master’s thesis, which is a thirty-page document. he received some feedback from his professor in the form of comments, but does not see where the comments are. what is the fastest way for hassan to find the feedback?
Answers: 3
image
Computers and Technology, 25.06.2019 00:30, jayzelgaspar8005
You are to write a series of steps that anyone could follow to solve the following three problems: 1. even odd a. assume that someone tells you a number (an integer number) b. you hear the number and respond with the word even or odd 2. average a. assume that someone tells you between 3 and 5 numeric values. b. you hear the numbers and respond with the average is some number 3. dog or cat a. explain to a child the differences between a dog and a cat. b. your explanation could be used by a child or anyone to distinguish the difference between a dog and a cat
Answers: 1
image
Computers and Technology, 25.06.2019 04:00, edjiejwi
Plz there is a problem with my account. i no longer have ! ( hand, ambitious, virtuoso etc.) it's like getting brainliest means nothing. how do i get ranks back?
Answers: 1
image
Computers and Technology, 25.06.2019 22:30, 21hendlill
If you were working on a mainframe, which of the following operating systems would you most likely be using? linuxmacintoshmicrosoft windowsunix
Answers: 1
You know the right answer?
Write a class named car that represents a car. your car class should have the followning: 1. instanc...

Questions in other subjects:

Konu
Mathematics, 24.11.2020 22:10