//help please to solve this problem for multiple programs
//with arrays.
//The purpose of this program is to calculate the car charges
//in a parking lot.  this program is working for 1 car.
//My assignment is to make a program that works for multiple cars
//at the same time.
//to make this program work, two arrays are required one for the 
//entrance time and one for the plate numbers.  when "e" is chosen,
//the entrance information is entered and loaded in these arrays.
//when a car is exiting, the user enters a "x" and the program asks for
//the plate number to find the car and the time of entrance.
//if car in lot the program will let you input the exit time and print a
//sample receive with the total time and charge

#include <iostream>
#include <fstream>
#include <algorithm>

using namespace std;
const int ARRAY_SIZE = 10;

//prototypes
int readTime(int& timeIn);
double calculateCharge(int& timeIn, int& timeOut);
int carTimeIn[10];
int findStall();  //file scope arrays
char carLicenseIn[10];
void initializedArray(char carLicenseIn[], int carTimeIn[]); 


int main()

{                
    char userOption;
    int timeIn, timeOut;                             /* User option */
  //initialized arrays  
 initializedArray(carLicenseIn, carTimeIn);     
//starts the interface with the user
    do
    {
    printf("\nEnter one of the following:\n\
\tE or e - If the car is entering \n\
\tX or x - If the car is exiting\n\
\tQ or q - If you want to quit program\n\
\n\tEnter Option: ");

cin >> userOption;
// user options explained above with the switch command   
    switch(userOption)
    {
 //if user choses q program terminates
        case 'Q':
        case 'q':     
return 0;
//if user choses e program executes the readTime prototype
       case 'E':
        case 'e':
//calls the readTime prototype      
        readTime(timeIn); 
        break;
// if user choses x program executes the calulateCharge Pro.        
        case 'X':
        case 'x':
// calls the calculateCharge prototype             
        calculateCharge(timeIn, timeOut);       
        break;
//if user choses other characters unrecognized option       
        default:
        cout << "?Unrecognized option: \""
             << userOption << "\" " << endl << endl;
        break;
    }
//repeats the above sequence until q is entered to terminate program
    } while (userOption != 'Q');

     cout << "[normal exit]\n";
    system("pause");
  }

//prototype
int readTime(int& timeIn)
{

     int hourTimeIn, minuteTimeIn;
     char morningOrAfternoon; 
     timeIn = 0;
     char carLicense;
//interface with the user to enter the entrance time    
cout << "Enter the vehicle license of the incoming car: ";    
        cin >> carLicenseIn;
        cout << "Enter the time of entrance" << endl;
        cout << "hour 1-12 only:";
        cin >> hourTimeIn;
        cout << "Minuter 1-59 only:"; 
        cin >> minuteTimeIn;
        cout << "AM (a) or PM (p):";
        cin >> morningOrAfternoon;
//Formula to get the entrance time to minutes       
    switch (morningOrAfternoon)
    {
        case 'p':
             timeIn = 60*(12 + hourTimeIn) + minuteTimeIn;
         break;
        case 'a':
             timeIn = hourTimeIn*60 + minuteTimeIn;
             break;
        default:
             cout<< "Please enter the an (a) for am and (p) for pm";
            }
//array read not working properly to save the time
//every time the car is entered
        for (timeIn; timeIn < ARRAY_SIZE; timeIn++)
        cin >>  carTimeIn[timeIn]; 
        cout << timeIn;    
}

//prototype
void initializedArray(char carLicenseIn[10], int carTimeIn[10])
{
int index;

for (index = 0; index < ARRAY_SIZE; index++)
    carLicenseIn[index] = 0;

for (index = 0; index < ARRAY_SIZE; index++)
    carTimeIn[index] = 0;
}

//prototype to calculate the charge and time of entrance
double calculateCharge(int& timeIn, int& timeOut)
{
       int hourTimeIn, timeParked, minuteTimeIn;
     char morningOrAfternoon; 
     double carCharge;
//interface with the user to enter exit time          
       cout << "Enter the vehicle license of the incoming car: "; 
        cin >> carLicenseIn;
        cout << "Enter the time of exit" << endl;
        cout << "hour 1-12 only:";
        cin >> hourTimeIn;
        cout << "Minuter 1-59 only:"; 
        cin >> minuteTimeIn;
        cout << "AM (a) or PM (p):";
        cin >> morningOrAfternoon;
//Formula to get the exit time to minutes
    switch (morningOrAfternoon)
    {
    case 'p':
             timeOut = 60*(12 + hourTimeIn) + minuteTimeIn;
      break;

        case 'a':
             timeOut = hourTimeIn*60 + minuteTimeIn;
             break;

        default:
             cout<< "Please enter the an (a) for am and (p) for pm";
                } 

//just to output and make sure the right data is being calculated 
        cout << timeIn << endl;
        cout << timeOut << endl;  
//formula for the parking time with
//multiple categories        
    timeParked = ((timeOut) - (timeIn))/60 +1;
    cout << timeParked << endl;
    if (timeParked < 2 )
    carCharge = 5.50;
    else if ((timeParked >= 2) && (4 >= timeParked))
    carCharge = timeParked * 2.75;
    else if (timeParked >= 4 && 6 >= timeParked)
    carCharge = 4*2.75 + (timeParked-4)*1.75;
    else if (timeIn > 1060)
    carCharge = 5.00;
    else
    carCharge = 18.00;
//outputs the total charge  
   cout << " the total charge is " << carCharge;     
}
Salem commented: posts > 10 and code tags no where to be seen - READ THE RULES -3

By multiple cars do you mean that the program can be run simultaneously or that the user can keep entering the scenario until they dont want to anymore?

for (timeIn; timeIn < ARRAY_SIZE; timeIn++)
{
cin >> carTimeIn[timeIn]; 
cout << timeIn; 
}

your missing a bracket after the for loop

[EDIT]
A couple of things I have noticed. There is poor indentation in your code. Your missing so many brackets and therefore your code will not work well inaddition to looking unreadable. Plese read this link.

In addtion, your main and other return type programs are not returning anything. I am not sure what you want to return in them but you will not get errors. Your main should always "return 0". Also check these functions

int readTime(int& timeIn) and
double calculateCharge(int& timeIn, int& timeOut)

They ,must return something

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.