Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CSC111 Lab Object Oriented Programming - Lab IIII ... Lab 9 ... Create a project Lab09 Q1) Write a Java class Car that represent a

image text in transcribed

CSC111 Lab Object Oriented Programming - Lab IIII ... Lab 9 ... Create a project Lab09 Q1) Write a Java class Car that represent a car in a car dealership. The car has the following attributes: - model: String. - year: int. The year the car was made. - mileage: int representing how many kilometers the car has drove. - soom: double. Best offer for the car so far. - hadd: double. Asking sale price. Must be greater than soom. The class has the following methods: - Car() - Car(String model, int year, int mileage, double soom, double hadd) - setters and getters for model, year, mileage, soom and hadd. - similar(Car c):boolean Compares two objects, the calling object and the argument c and returns true if they are similar, false otherwise. Two cars are similar if they have same model, year and within 10k of eachother mileage. For example, 2014 ford with mileage 120K is similar to a 2014 ford with mileage 125K. - difference():double. the difference between soom and hadd. Must be positive. Write a class testCar that will do the following: 1. Declare objects car1 and car2 of class Car. 2. Read car attributes from the user using the both constructors. 3. Print both cars information. 4. Check if both cars are similar. 5. Ask the user repeatedly to enter soom for car1 until soom is within 2% of hadd. 6. Print both cars information. 7. Feel free to try creating additional objects, read their data and manipulate them. 8. exit. Sample Run Please enter car1 model, year, mileage, hadd and soom Ford 201820000010000080000 Please enter car2 model, year, mileage, hadd and soom Toyota 2019200000300000250000 This car is a ford and was made in 2018. It has 200000KM and soom is 80000.0 Hadd is 100000.0 This car is a Toyota and was made in 2019. It has 200000KM and soom is 250000.0 Hadd is 300000.0 Cars are not similar Car1 difference between soom and hadd must be less than 2000.0 The difference is =20000.0SR -e enter another soom 85000 ference is =15000.0SR nter another soom> 98000 ierence is =2000.0SR c enter another soom> 98001 The difference is =1999.0 SR which is less than 2000.0

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

Relational Database And SQL

Authors: Lucy Scott

3rd Edition

1087899699, 978-1087899695

More Books

Students also viewed these Databases questions