View Single Post
Join Date: Jul 2005
Posts: 47
Reputation: karen_CSE is an unknown quantity at this point 
Solved Threads: 0
karen_CSE karen_CSE is offline Offline
Light Poster

Re: airplane seating prices

 
0
  #8
Jul 26th, 2005
Hi,
while waiting for help, I help myself a bit (LOL that sounds so akward). ANYWAY.

Instead of the original code, which is to ask for the price of 12 rows:

//initialize seat prices for each of the 12 rows
for (int i = 0; i < 12; i++)
{
cout << "\nPlease enter ticket price for Row " << i + 1 << ": ";
cin >> ticketPrice [i];
}

I changed it to this:

  1.  
  2. void main ()
  3. {
  4. int choice;
  5. char response = 'Y';
  6.  
  7. float seatprices[4] = { 4.0, 5.0, 6.0, 7.0 }; //just some defaults here: ASWL
  8. char seattypes[4][12] = { "Aisle", "Regular", "Window", "Leg Room" }; //this makes it possible to do input with a loop
  9.  
  10.  
  11. cout << "WELCOME TO C++ AIRPLANES SEATING ALLOCATION SYSTEM!\n";
  12. cout << "*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n";
  13.  
  14. //initialize airplane with labels (A, S, W, L) - all seats available
  15. for (int y =0; y < 1; y++)
  16. for (int q = 0; q <4; q++)
  17. airplane [y][q] = 'L'; //Leg Room Seats
  18. for (y = 1; y < 12; y++)
  19. {
  20. for (int z = 0; z < 4; z++)
  21. {
  22. for (int x = 0; x < 1; x++)
  23. airplane [y][x] = 'S'; //Regular Seats
  24. for (int v = 1; v < 3; v++)
  25. airplane [y][v] = 'A'; //Aisle Seats
  26. for (int w = 3; w <4; w++)
  27. airplane [y][w] = 'W'; //Window Seats
  28. }
  29. }
  30.  
  31. //seatypes inputs
  32. for (int i = 0; i < 4; i++)
  33. {
  34. cout << "Please enter price for " << seattypes[i] << " seats: ";
  35. cin >> seatprices[i];
  36. cout << endl;
  37. }

and now I have to find a new way to display this in the DisplayPrices () function, and I don't think I did it right.

  1. void DisplayPrices(float seatprices[], float seattypes[])
  2. {
  3. cout.precision(2);
  4. cout.setf(ios::fixed | ios::right);
  5. cout << "\n\tTicket Prices By Seat Types: " << endl << endl;
  6. cout << "\tSeat Types Price" << endl;
  7. cout << "\t------ -------" << endl << endl;
  8. for (int m = 0; m < 4; m++)
  9. seattypes[m];
  10. for (int n = 0; n < 4; n++)
  11. seatprices[n];
  12.  
  13. char keyin;
  14. cout << endl << endl;
  15. cout << "\nPress an alphanumeric key to continue.";
  16. cin >> keyin;
  17. }

can you tell me what I did wrong in the code above?

Karen
Reply With Quote