Answer to Question #212212 in C++ for Hemambar

Question #212212

Create a class called CarPark that has the members CarRegnno(int), ChargePerHour(int) and

ParkingDuration(float). Set the data and show the charges and parked hours of a car based on

CarRegnNo. Make two member functions for setting and showing the data. Member function should

be called from other functions.


1
Expert's answer
2021-07-02T04:11:07-0400
#include <iostream>
using namespace std;

class CarPark {
public:
    void set(int rent_no, int charge, float duration) {
        car_rent_no_ = rent_no;
        charge_pre_hour_ = charge;
        park_duration_ = duration;
    }

    void show() {
        std::cout << "Rent No: " << car_rent_no_ << '\n'
            << "Charge per hour: " << charge_pre_hour_ << '\n'
            << "Duration: " << park_duration_ << '\n';
    }
private:
    int car_rent_no_;
    int charge_pre_hour_;
    float park_duration_;
};

int main() {
    CarPark park;
    park.set(1, 10, 180.f);
    park.show();
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS