Hello everyone;
I did a program using arrays -for the first time-
I've got errors, I fixed some and there are others left that I couldn't straighten
any help is highly appreciated
here is the code :
# include <iostream>
# include <iomanip>
using namespace std;
int read_car (int cars[], int n);
double read_time (double time[], int n);
double charge (time[]);
void print ();
double sum_time, sum_charge;
int main()
{
int time;
int cars[n];
int n;
cout << "Welcome to the Car Parking fee calculater." <<endl;
cout << "Please enter the numbers of the cars." <<endl;
cin >> n;
read_car (cars,n);
read_time(time,n);
charge(time,n);
print ();
return 0;
}
//1
int read_car (int cars[], int n)
{
int i;
for (i=1; i<=n; i++)
cin >> cars[i];
return cars;
}
//2
double read_time (double time[], int n)
{
int i;
sum=0;
for (i=1; i<=n; i++)
cin >> time[i];
time[i] = ceil(time);
sum_time= sum + time;
return time;
}
//3
double charge (double time[],int n)
{
double charge;
double sum=0;
for ( int i=1; i<=n; i++)
{
if (time <= 3.00)
charge= 2.00;
if (time == 24.0)
charge = 10.0;
else
charge = (time - 3)*0.5 + 2.00;
sum_charge= sum+charge;
return charge;
}
}
//4
void print (n)
{
cout << left;
cout << setw(6) <<"Car"
<< setw(6) <<"Hours"
<< setw(6) <<"Charge"
<<endl;
cout <<"__________________"<<endl;
for (i=1; i<=n; i++)
{
cout << setw(6) << i
<< setw(6) << time[i]
<< setw(6) << charge (time,n)
<<endl;
}
cout <<"__________________"<<endl;
cout << setw(6) <<"Total"
<< setw(6) << sum_time
<< setw(6) << sum_charge
<<endl;
}