(Please Help) Parking Garage Functions

I don't know how to get the programs to call each other, please help me.

#include<iostream>
using namespace std;



int intro() {
cout<<"The first 30 minutes you are here cost $0.50.";
cout<<"Through the first 8 hours $0.35 cents will be charged every 30 minutes";
cout<<"After the first 8 hours $0.25 cents will be charged each additional 30 minutes until you have left";
}

void getinfo() {
int min;
cout<<"How many minutes have you been parked here?";
cin>>min;
}
int calc(min){
double cost;
double mc;
min=mc;
if (mc <= 30)
cost = 0.50;
else if (mc <= 480)
cost = 0.50 + (((mc / 30) - 1) * 0.35);
else if (mc > 480)
cost = 5.75 + (((mc - 480) / 30) * 0.25);

}
int main(){
int min;
double cost;
cout<<"welcome to the parking garage!";
int intro();
void getinfo();
int calc();
cout<< "you've been parked here "<< min<< "minutes,"<<"the fee is $ "<<cost;


system("pause");
return(0);
}
Last edited on
try this: (make min a double)

double cost;
if (min <= 30)
cost = 0.50;
else if (min <= 480)
cost = 0.50 + ((ceil(min / 30) - 1) * 0.35);
else if (min > 480)
cost = 5.75 + (ceil((min - 480) / 30) * 0.25);
cout << cost;
Last edited on
what's ceil?
If min = 128, min / 30 = 4.26666. You want to charge them for 2 1/2 hours, not 2 hours and not 2 hours and 26 minutes because you're charging them by half-hours. ceil just rounds the number up. Ex: ceil(4.2666) would equal 5 half-hours (or 2 1/2 hours)

And you have to make min a double for this to work.
Last edited on
is there another way to round up the number?
Do you have any advice for calling in between my programs?
Just put this at the top of the page and ceil will work. It's the easiest way.
#include <math.h>

Do you have more than one .cpp file? Or are you referring to how to call the functions?
Functions should be written:
1
2
3
4
return_type function_name (parameters)
{
      [code here]
}


You need a "main" function. Then call the others by writing
1
2
3
function_name();
function2_name();
...etc...

in the main function.
Last edited on
I updated my main function up top but idk how to get them to call each other or if i'm using the correct functions for each individual program
Topic archived. No new replies allowed.