Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include "stdafx.h"
#include "iostream"
using namespace std;
class Parking
{
int hour;
public:
void hour_set(int var)
{
hour = var;
}
int hour_get(){
return hour;
}
int calculateCharges()
{
int result=500;
if (hour <= 3)
result = 500;
else
result = ((hour-3) * 150) + 500;
if(result > 2500)
result = 2500;
return result;
}
};
void main()
{
int x;
Parking car1, car2 , car3;
cout << "Please Enter Hour Pass Your Car On This Parking : ";
cin >> x;
car1.hour_set(x);
cout << endl;
cout << "Please Pay This Many Money For " << car1.hour_get() << " Hour : " << car1.calculateCharges() << endl << endl;
cout << "Please Enter Hour Pass Your Car On This Parking : ";
cin >> x;
car2.hour_set(x);
cout << endl;
cout << "Please Pay This Many Money For " << car2.hour_get() << " Hour : " << car2.calculateCharges() << endl << endl;
cout << "Please Enter Hour Pass Your Car On This Parking : ";
cin >> x;
car3.hour_set(x);
cout << endl;
cout << "Please Pay This Many Money For " << car3.hour_get() << " Hour : " << car3.calculateCharges() << endl << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.