Create a super class called Car | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Create a super class called Car

A. Create a super class called Car. The Car class has the following fields and methods. ā€¢ int speed; ā€¢ double regularPrice; ā€¢ String color; ā€¢ getSalePrice() method which is just increase the regular price to 10%; B.Create a sub class of Car class and name it as Truck. The Truck class has the following fields and methods. ā€¢ intweight; ā€¢ double getSalePrice(); // Ifweight>2000,10%discount. Otherwise, 20%discount C. Create a Main class Create an instance of Truck class and initialize all the fields with appropriate values. Use super(...) method in the constructor for initializing the fields of the superclass. Display the sale prices of Truck instance.

12th Apr 2021, 2:02 AM
Onin Abellanosa
Onin Abellanosa - avatar
2 Respostas
+ 1
here's the solution boi: https://code.sololearn.com/cF7Umh1Y09wv/?ref=app next time, provide an attempt. also, your question is now my property.
12th Apr 2021, 2:35 AM
Rellot's screwdriver
Rellot's screwdriver - avatar
12th Apr 2021, 2:14 AM
ä½ ēŸ„é“č¦å‰‡ļ¼Œęˆ‘也ę˜Æ
ä½ ēŸ„é“č¦å‰‡ļ¼Œęˆ‘也ę˜Æ - avatar