Beginner Having Trouble

I recieved this assignment for my beginner's c++ course and I am having trouble even beginning to write pseudocode for this. I was wondering if anyone would be able to help me with this. Thanks!


Imagine a plane with 100 seats and 100 passengers waiting to board
the plane. Every passenger has a boarding pass with a reserved seat
number. The first passenger to board the plane drops their boarding
pass. Rather than pick it up, he continues onto the plane and sits
in a randomly selected seat. Every person boarding after him uses
the following algorithm to decide where to sit: if their assigned seat
is available, they sit in it; if their assigned seat is taken then they
randomly choose one of the remaining available seats.
The purpose of the simulation is to help us answer three questions:
(1) How often does the last person on board get to sit in their assigned
seat? (2) How often does the penultimate (next-to-last) person get to
sit in their assigned seat? (3)What percentage of people typically get to
sit in their own seat? To obtain reasonable answers to these questions
you should run the simulation 10000 times and average the results.
Give answers to all three questions as percentages. Finally, display
the seating obtained from the final run of your simulation. Assume
the plane has 17 rows with 6 seats in each row except for the last row
which only has 4 seats. Assume the seats and passengers are numbered
0 through 99. The first row contains seats 0 through 5 running right
to left as you look back from the front of the plane. If everyone sits in
their assigned seat the seating would look like this:
05 11 17 23 29 35 41 47 53 59 65 71 77 83 89 95
04 10 16 22 28 34 40 46 52 58 64 70 76 82 88 94
03 09 15 21 27 33 39 45 51 57 63 69 75 81 87 93 99
02 08 14 20 26 32 38 44 50 56 62 68 74 80 86 92 98
01 07 13 19 25 31 37 43 49 55 61 67 73 79 85 91 97
00 06 12 18 24 30 36 42 48 54 60 66 72 78 84 90 96

An important aspect of your solution will be the representation of seats
on the plane, and, in particular, keeping track of the remaining avail-
able (unoccupied) seats at any time. Use an integer array to represent
the seats and use a special value (-1 is a good choice) to indicate that
a seat is unoccupied. The ith element of the array represents the ith
seat. Use integer values to represent passengers. For example, if the
first passenger (0) sits in seat 52, then the 52nd element of your array
should be assigned the value 0. In the proper seating given above the
ith element of the array contains the value i.
When a passenger is forced to sit in a seat other than their assigned
seat you must find them a random unoccupied seat. You must not
generate random seat numbers (between 0 and 99) until you find one
that is unoccupied. Instead, you should design a way to generate one
random number to select the passengers seat. (There are a couple ways
of doing this.)
Be sure practice good coding style. Do not use literal constants (like
100 or 100000) in your programming - use defined constants instead.
Use appropriate data structures (arrays) and looping constructs. Use
functions where appropriate to keep the size of your main program
to a reasonable size.
closed account (4Gb4jE8b)
that's beginner's eh? alright, seems a little high for the beginners class at my school but hey w/e.

Anyway, we don't help anyone who hasn't shown that they put at least a little work into it. Do you have an algorithm or any code written at all?
Topic archived. No new replies allowed.