C++ airline flight

So I was given this problem and I'm not sure how to do the following. Could someone help me with this plz.

Copa Airline has three planes with a capacity of 100 passengers each. The company has 3 routes, which fly once a day.

Panama- Bogota Route 1

Panama- Miami Route 2

Panama- Cancun Route 3

It has been the company's policy to cancel a flight when:
The number of reserved tickets is less than 20% of the plane's quota.

Develop a program that finds the following:
-Number of passengers per flight

- Routes to which the flight was completed

-Number of flights canceled

The file contains the route, number of reserved passages.
Hello DigiLei,

It would be helpful to post the input file or at least a goo sample if it so everyone knows what we are working with.

Have you done anything with how to store the information once read in?

Do you have any code yet or is it you just do not know what to do?

The instructions are bit sparse is this all of them?

I would start with the code to open the file and then read the file. You will need to figure out what you will be storing the information in a class or a struct? After that will you want an array or vector to store everything?

These are questions to work out before you get started. It may also help to put this down on paper first to get an idea of what you need.

Last point do this in small steps, get them working before you move on to the next step.

Hope that helps,

Andy
Sadly, I don't know what to do.

Yes, that's all of them.

And well my professor wanted me to display the input using for loops.
The instructions are ridiculous. Another troll?
No, I'm dead serious.

If anyone here was the troll, it would be my professor for being vague.
It's senseless.
I know right.
May be, something like this is what is expected:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#include <fstream>

int main () {

    const unsigned int NROUTES = 3 ; // The company has 3 routes

    // there is no route 0, route_names[0] is not used
    const char* const route_names[NROUTES+1] = { "", "Panama- Bogota", "Panama- Miami", "Panama- Cancun" } ;

    const unsigned int NSEATS = 100 ; // planes with a capacity of 100 passengers each.

    // cancel a flight when the number of reserved tickets is less than 20%
    const unsigned int MIN_RES_TICKETS = NSEATS * 20 / 100 ;

    std::ifstream file( "reservations.txt" ) ; // open the file for input

    // The file contains the route, number of reserved passages.
    // read them in one by one and update the count of reserved seats
    unsigned int num_seats_reserved[NSEATS+1] = {0} ; // num_seats_reserved[0] is ignored

    unsigned int route_num ;
    unsigned int cnt_res_seats ;
    while( file >> route_num >> cnt_res_seats ) {

        if( route_num <= NROUTES ) // valid route number
            num_seats_reserved[route_num] += cnt_res_seats ;
    }

    for( unsigned int rt = 1 ; rt <= NROUTES ; ++rt ) { // for each route

        std::cout << "route #" << rt << ". " << route_names[rt]
                  << " reserved seats: " << num_seats_reserved[rt] << '\n' ;

        if( num_seats_reserved[rt] >= MIN_RES_TICKETS ) { // the flight is not cancelled

            // ... (TO DO)
        }
        else { // this flight is cancelled

            // ... (TO DO)
        }
    }

    // print totals (TO DO)
}
Gosh, that's amazing! It's the closest to what I think the problem asks for. Thanx.
Topic archived. No new replies allowed.