Go through your books on declaring and using functions - that'll help you a lot.
Code:
/* Calculate the total charges and the total hours for the
parking garage. */
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
//These are prototypes (look it up) - they need semicolons
void calculatecharges (int hoursa, int hoursb, int hoursc);
int main()
{
int a, b, c;
cout<<"Enter the number of hours for CAR 1:";
cin>>a;
cout<<"Enter the number of hours for CAR 2:";
cin>>b;
cout<<"Enter the number of hours for CAR 3:";
cin>>c;
calculatecharges(a, b, c);
return 0;
}
void calculatecharges(int hoursa, int hoursb, int hoursc)
{
int costa = 0;
int costb = 0;
int costc = 0;
if(hoursa <= 3)
costa = 2;
else if (hoursa >= 17)
costa = 10;
else
costa = 2 + ((hoursa-3) * .5);
if(hoursb <= 3)
costb = 2;
else if (hoursb >= 17)
costb = 10;
else
costb = 2 + ((hoursa-3) * .5);
if(hoursc <= 3)
costc = 2;
else if (hoursc >= 17)
costc = 10;
else
costc = 2 + ((hoursc-3) * .5);
cout<<"CAR 1 CHARGES: "<<costa<<endl;
cout<<"CAR 2 CHARGES: "<<costb<<endl;
cout<<"CAR 3 CHARGES: "<<costc<<endl;
}