Answer to Question #211649 in C++ for Hemambar

Question #211649

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-01T10:35:00-0400
#include <iostream>
using namespace std;


class CarPark 
{
private:
	//Create a class called CarPark that has the members CarRegnno(int), ChargePerHour(int) and ParkingDuration(float). 
	
	int CarRegnno;
	int ChargePerHour;
	float ParkingDuration;
public:
	//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. 
	


	void setData(){
		cout<<"Ente car regn. no: ";
		cin>>CarRegnno;
		cout<<"Ente car charge per hour: ";
		cin>>ChargePerHour;
		cout<<"Ente parking duration (hours): ";
		cin>>ParkingDuration;
	}
	
	void sho2Data(){
		cout<<"Car regn. no: "<<CarRegnno<<"\n";
		cout<<"Car charge per hour: "<<ChargePerHour<<"\n";
		cout<<"Parking duration (hours): "<<ParkingDuration<<"\n";
		cout<<"The charges: "<<calculateCharges()<<"\n";
	}
	//Member function should be called from other functions.
	float calculateCharges(){
		return ChargePerHour*ParkingDuration;
	}
	
};


int main ()
{
	CarPark carPark;
	carPark.setData();
	carPark.sho2Data();


	system("pause");
	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

Hemambar
29.06.21, 08:55

Sir, Why it is not answered

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS