Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - C++ expressway Toll Collection System Program
C++ expressway Toll Collection System Program
# include & ltiostream.h & gt

const int unit car = 10; //Declare three constants

const int unittruck = 25

const int unit bus = 15;

Class Free // define classfree.

{

Int car, cafe//define six class member integer variables.

International truck transportation fee;

int bus,busfee

Public:

The Free() // constructor (with the same name as the class) initializes the related variables.

{

car = car fee = truck = truck fee = bus = bus fee = 0;

}

Void cars() // defines a class public member function, the same below.

{

car++;

carfee+= unit car;

}

Invalid truck ()

{

truck++;

truck fee+= unit truck;

}

Invalid bus ()

{

bus++;

bus fee+= unit bus;

}

Invalid process ()

{

int no,n = 0;

Cout & lt& lt" 1: bus 2: truck 3: bus 0: exit "< & ltendl// output (similar to printf)

while ( 1)

{

cout & lt& lt" " " & lt& lt++ n & lt; & lt"- Model: ";

CIN & gt; & gt No; //input

Switch (No)

{

Case 0: broken;

Case1:cars (); Break;

Case 2: truck (); Break;

Case 3: Bath (); Break;

Default value: cout & lt& lt "Wrong vehicle type input!" & lt& ltendl

}

if(no = = 0)break;

}

}

Empty display ()

{

Cout & lt& lt "The cost statistics are as follows:"

Cout & lt& lt "Bus:" << Car<& lt "Subtotal of vehicle expenses:" < & ltcarfee & lt& ltendl.

Cout & lt& lt "Truck:"

cout & lt& lt" Bus:" < & lt; Bus<& lt "Subtotal of vehicle expenses:" < & ltbusfee & lt& ltendl.

Cout & lt& lt "Total cost:"

}

};

void main()

{

Free obj// Define object obj

obj . process(); //Call the public function of the obj object

obj . display();

}