Answered step by step
Verified Expert Solution
Question
1 Approved Answer
How to write a program that create a car class with : instance variables name and mpg (make public) No need for a main() method
How to write a program that create a car class with:
instance variables name and mpg (make public)
No need for a main() method
In a separate file, create a CompareCars class with a main()method
create 2 instances of car using new
set the name and mpg for each
instance variables are public, so use the name an mpg to access the instance variables
compare the fuel efficiency of your 2 cars and print out which is more efficient to the screen.
finally change your variable from public to private
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started