Answer:
Step-by-step explanation:
The following code is written in Java. It creates a Cars class that has a variable for checkEngine and carMiles. Then the constructor accepts the carMiles and checks if the carMiles is greater or less than 5000 and adjusts the checkEngine light or not. Two test objects have been created and the output can be seen in the attached image below.
class Cars {
boolean checkEngine;
int carMiles;
public Cars(int carMiles) {
this.carMiles = carMiles;
if (carMiles > 5000) {
this.checkEngine = true;
} else {
this.checkEngine = false;
}
}
public boolean isCheckEngine() {
return checkEngine;
}
public int getCarMiles() {
return carMiles;
}
}