You are a supercar engineer and currently setting the engine's horsepower. Complete the given program by completing methods to s | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

You are a supercar engineer and currently setting the engine's horsepower. Complete the given program by completing methods to s

#include <iostream> using namespace std; //class definition class Car{ //private area private: int horsepowers; //public area public: //complete the setter function void setHorsepowers(int a) { horsepowers=a; } //complete the getter function int getHorsepowers() { if(horsepowers>800){ cout<<"Too much"; return horsepowers; } else{ return horsepowers; } } }; int main() { //getting input int horsepowers; cin >> horsepowers; //creating the object of class Car Car car; //setting the value for private member car.setHorsepowers(horsepowers); //printing the value of private member cout << car.getHorsepowers(); return 0; }

8th May 2021, 7:07 PM
Ashok Swami
Ashok Swami - avatar
1 Answer
+ 1
what do you need help with?
8th May 2021, 7:45 PM
Apollo-Roboto
Apollo-Roboto - avatar