Create a program called question2.cpp that creates a class called Car. Each car has a name (string), a model year, and

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Create a program called question2.cpp that creates a class called Car. Each car has a name (string), a model year, and

Post by answerhappygod »

Create a program called question2.cpp that creates a classcalled Car. Each car has a name (string), a model year, and a speed. The constructor of the class initializes theclass’s object with the car's name, model year, and speed. There is a function also called void accelerate(floatx), and float getSpeed(). The first one increases the current speed of the car by a value x, and the secondone returns the current speed of the car in km/h.This is a sample usage of the class in main: Car a (“Ford”, 2019, 37.8);a.accelerate(20.4); a.getSpeed();
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply