Hey all,
Im having a lot of problems with a program that i have to write.
Basically the program accepts a room number, name, number of people booking is for and a destination. (Max = 10 people) It then calculates the costs of the trip and puts the passengers into suitable transport arrangements e.g. mini_bus etc.
I have it down to 11 errors, 14 warnings, but most of the errors are
'>=' : 'int [10]' differs in levels of indirection from 'const int '
i have no idea what this is, maybe something with the arrays, not sure.
Could someone have a look at this and maybe tell me what im doing wrong?
Also if there is anything else you spot that is wrong i would appreciate if you could tell me how to fix it.
Sorry to put all the code in but i dont know where the probs are
Thanks to anyone that puts time aside for this.
Here is the code
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#define SIZE 10
/* Declare Ints etc. Here */
void instructions (void);
void summary (void);
void close (void);
char name[SIZE][20];
char destination[SIZE];
int room_number[SIZE];
int num_people[SIZE];
int i=0;
int choice;
int air_st_cost = 0, air_lt_cost = 0, air_mb_cost = 0, train_st_cost =0,train_lt_cost =0, train_mb_cost = 0; /* Floating point integers*/
int city_st_cost = 0, city_lt_cost = 0, city_mb_cost = 0, total;
int num_st_air = 0, num_lt_air = 0, num_mb_air = 0, num_st_train = 0, num_lt_train = 0, num_mb_train = 0;
int num_st_city = 0, num_lt_city = 0, num_mb_city = 0;
int remainder_air = 0, remainder_train = 0, remainder_city = 0;
int num_ppl_air = 0, num_ppl_train = 0, num_ppl_city = 0;
//************************************************** *
main()
{
void instructions (void);
void summary (void);
void close (void);
return 0;
}
//************************************************** *
void instructions (void){
for (i=0;i<=SIZE-1;i++)
{
printf("Enter Name:");
scanf("%c", &name[i]);
fflush(stdin);
printf ("\nEnter The Room Number: ");
scanf ("%d",&room_number[i]);
fflush(stdin);
printf ( "Enter the number of people you are booking for:" );
scanf ("%d", &num_people[i]);
printf ( "\t\t***************************\n\a" );
printf ( "\t\tDestination for Paseenger #\n" );
printf ( "\t\t***************************\n\n\n" );
printf ( "\tA:" );
printf ( "\t\tAirport\n\n" );
printf ( "\tB:" );
printf ( "\t\tTrainstation\n\n" );
printf ( "\tC:" );
printf ( "\t\tCity\n\n" );
scanf ("%c", &destination[i]);
i++;
//************************************************** *
//**************************************************
switch (destination) {/* Switch for incrementation and calculation of destinations and vehicles to those destinations */
case 'A' : case 'a':
{
if (num_people[i] > 15)
num_mb_air += num_people[i] / 15;
num_people[i] %= 15;
if (( num_people[i] >= 1 ) && ( num_people[i] <= 3 )) /* Tests conditions according to taxi specifications*/
num_st_air++;
if (( num_people[i] >= 4 ) && ( num_people[i] <= 6 ))
num_lt_air++;
if (( num_people[i] >=7 ) && ( num_people[i] <= 15 ))
num_mb_air++;
}
else
num_ppl_air += num_people[i];
break;
//************************************************** *
case 'B' : case 'b': /* Switch enabling train station function */
{
if (num_people > 15)
num_mb_train += num_people / 15;
num_people %= 15;
if (( num_people >= 1 ) && ( num_people <= 3 )) /* Tests conditions according to taxi specifications*/
num_st_train++;
if (( num_people >= 4 ) && ( num_people <= 6 ))
num_lt_train++;
if (( num_people >= 7 ) && ( num_people <= 15 ))
num_mb_train++;
}
else
num_ppl_train += num_people;
break;
//************************************************** *
case 'C' : case 'c': /* Switch enabling city function */
{
if (num_people > 15)
num_mb_city += num_people / 15;
num_people %= 15;
if (( num_people >= 1 ) && ( num_people <= 3 )) /* Tests conditions according to taxi specifications*/
num_st_city++;
if (( num_people >= 4 ) && ( num_people <= 6 ))
num_lt_city++;
if (( num_people >= 7 ) && ( num_people <= 15 ))
num_mb_city++;
}
num_ppl_city += num_people;
break;
//************************************************** ************************************************** **********
default:
printf ( "\t---------------------------------\n"); /* Destination specification not valid */
printf ( "\t Wrong Destination Entered.\n\n ");
printf ( "\t---------------------------------\n");
//************************************************** ************************************************** **********
printf("Do you want to change the information that you have just entered? (Y/N)\n"); /* Prompt user decision to change previous input - Yes or No*/
scanf("%c", &choice);
if ((choice == 'Y') || (choice == 'y'))
--i;
}
/*)*/break;
}
while ( choice != 'Y' || 'y' );
num_mb_air += ( num_ppl_air / 15 );
remainder_air = num_ppl_air % 15;
if (( remainder_air >=1) && ( remainder_air <=3))
num_st_air++;
else if (( remainder_air >= 4) && ( remainder_air <= 6))
num_lt_air++;
else if (( remainder_air >= 7) && ( remainder_air <= 15))
num_mb_air++;
num_mb_train += ( num_ppl_train / 15 );
remainder_train += num_ppl_train % 15 ;
if (( remainder_train >=1) && ( remainder_train <=3))
num_st_train++;
else if (( remainder_train >= 4) && ( remainder_train <= 6))
num_lt_train++;
else if (( remainder_train >= 7) && ( remainder_train <= 15))
num_mb_train++;
num_mb_city += ( num_ppl_city / 15 );
remainder_city += num_ppl_city % 15 ;
if (( remainder_city >=1) && ( remainder_city <=3))
num_st_city++;
else if (( remainder_city >= 4) && ( remainder_city <= 6))
num_lt_city++;
else if (( remainder_city >= 7) && ( remainder_city <= 15))
num_mb_city++;
air_st_cost = num_st_air * 60; /* Calculates the value of destination costs */
air_lt_cost = num_lt_air * 100;
air_mb_cost = num_mb_air * 140;
train_st_cost = num_st_train * 45;
train_lt_cost = num_lt_train * 70;
train_mb_cost = num_mb_train * 110;
city_st_cost = num_st_city * 30;
city_lt_cost = num_lt_city * 50;
city_mb_cost = num_mb_city * 70;
total = air_st_cost + air_lt_cost + air_mb_cost + train_st_cost + train_lt_cost + train_mb_cost + city_st_cost + city_lt_cost + city_mb_cost; /* Calculates total variable value for output */
}
return;
}
//************************************************** *******************************
void summary (void){
total = air_st_cost + air_lt_cost + air_mb_cost + train_st_cost + train_lt_cost + train_mb_cost + city_st_cost + city_lt_cost + city_mb_cost; /* Calculates total variable value for output */
printf ( "\n\n" );
printf ( "************************************************* ****************");
printf ( "\n\n" );
/* Displays the final summary */
printf ("%22s\t%d\t%d\t%s\n", names[i],room_number[i],num_bookings[i],destination[i]);
printf ( "Type of Transport\tConferees\tDestination\tNumber Required\tCost\n" );
printf ( "*****************\t*********\t***********\t****** *********\t****\n" );
printf ( "*****************\t*********\t***********\t****** *********\t****\n" );
printf ( "\n\n" );
printf ( "Small Taxi \tAirport \t%7d%11c%7.2f\n", num_st_air, '$', air_st_cost);
printf ( "Large Taxi \tAirport \t%7d%11c%7.2f\n", num_lt_air, '$', air_lt_cost);
printf ( "Mini Bus \tAirport \t%7d%11c%7.2f\n", num_mb_air, '$', air_mb_cost);
printf ( "Small Taxi \tTrain Station\t%7d%11c%7.2f\n", num_st_train, '$', train_st_cost);
printf ( "Large Taxi \tTrain Station\t%7d%11c%7.2f\n", num_lt_train, '$', train_lt_cost);
printf ( "Mini Bus \tTrain Station\t%7d%11c%7.2f\n", num_mb_train, '$', train_mb_cost);
printf ( "Small Taxi \tCity \t%7d%11c%7.2f\n", num_st_city, '$', city_st_cost);
printf ( "Large Taxi \tCity \t%7d%11c%7.2f\n", num_lt_city, '$', city_lt_cost);
printf ( "Mini Mini \tCity \t%7d%11c%7.2f\n", num_mb_city, '$', city_mb_cost);
printf ( "\n\n\a" );
printf ("%66s\n", "*********" );
printf ("\tTotal Cost %39c%7.2f\n", '$',total);
printf ("%66s\n", "*********" );
getch ();
return;
}
//************************************************** *******************************
void close (void){
printf("In closing sequence\n\n\n");
return;
}