Movies: i am stuck not sure what to do

The program runs but i am stuck on the last part and this is what i am trying to do

Sample Input and Output:
Enter a movie name: Mummy II
Enter its ticketing capacity: 500
Enter number of the tickets sold: 492

Additional data (Y/N)? Y

Enter a movie name: Meet the Parents
Enter its ticketing capacity: 600
Enter number of the tickets sold: 600

Additional data (Y/N)? N
if the user does not want to continue, the program then outputs what is already stored. which is:

Movie/Capacity/Tickets Sold/Seats Available
------------------------------------------------------
Mumm II/500/492/8
Meet the Parents/600/600/0

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
#include <iostream>

int _tmain(int argc, _TCHAR* argv[])
{
    int capacity;
    char name[30];
    char userchoice;
    int sold;
Inputsection:

    cout << "Hello, Welcome to the movie purchase services:" << endl;
    cout << "Please enter a Movie name? Please indicate when you want to stop typing with a %" << endl;
    cin.getline(name, 30, '%');
   
    cout << "The Movie that you entered was:" << name << endl;
    cout << "What is the ticket capacity for this movie?" << endl;
    cin >> capacity;
   
    cout << "The movie capacity for this movie is:" << capacity << endl;

    cout << "The number of tickets that are sold for this movie are:" << endl;
    cin >> sold;
        cout << "The amount of tickets sold are:" <<  capacity - sold << endl;

        cout << " Would ou like to add additonal Information? [Y/N]" << endl;
        cin >> userchoice;
       if(userchoice== 'Y')
    {
        goto Inputsection;
       
    }

    system("PAUSE");
    return 0;
}


Last edited on
You have to use a vector or some type of data structure that can hold multiple values. A vector would be the easiest.

http://www.cplusplus.com/reference/stl/vector/
i was trying to use a loop to store the input of the user into the array, then be able to cout what is in the array. but i am not am not sure how to go about this part.
Use a vector.

Create the vector

1
2
3
std::vector<char*> name;
std::vector<int> capacity;
std::vector<int> sold;


After every cin statement add this
vector_name.push_back(value);

Then loop through and print out all the information.
well we are not up to vectors yet in our class. so i am not sure how to use it. can i use a regular for loop or a if statement.
Access a vector like a normal array.
i came up this for my program but still not working aww man i dont know what to do.
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
47
48
49
50
51
52
53
#include <iostream>
#include <string>
using std::string;
using std::cout;
using std::endl;
using std::cin;
int main()
{
    int n = 0;
    int capa[5], size;
    char name[30];
    char userchoice;
    int sold;
Inputsection:

    cout << "Hello, Welcome to the movie purchase services:" << endl;
    cout << "Please enter a Movie name? Please indicate when you want to stop typing with a %" << endl;
    cin.getline(name, 30, '%');
    
    cout << "The Movie that you entered was:" << name << endl;
    cout << "What is the ticket capacity for this movie?" << endl;
    cin >> size;
       // Reads n elements
    for(int i = 0; i <n;i++)
{
   cout<<" enter element "<<(i+1);
  cin>>capa[i];
  } 
       

    cout << "The movie capacity for this movie is:" << size << endl;

    cout << "The number of tickets that are sold for this movie are:" << endl;
    cin >> sold;
        cout << " Would you like to add additonal Information? [Y/N]" << endl;
        cin >> userchoice;
       
      if (userchoice == 'y')
     {
        goto Inputsection;
     }    
    if (userchoice == 'n')
    {
        for( int i = 0; i < 5; i++ ) {
       capa[i] = i + 1; 
       cout << capa[i] << endl;
    }
      
   system("PAUSE");
    return 0;
}

}
What are you trying to do?

Btw: If you learned that how to use goto in class, forget what you learned about it. goto is a terrible programming practice.
i am trying to write a program that continues to accept a movie name (a max of 30 characters), its ticketing capacity, and the number of the tickets sold until the user indicates to stop. The program should display, in table form with the column headings given below, the movie name, ticketing capacity, number of tickets sold, and number of seats available.
Sample Input and Output:
Enter a movie name: Mummy II
Enter its ticketing capacity: 500
Enter number of the tickets sold: 492

Additional data (Y/N)? Y

Enter a movie name: Meet the Parents
Enter its ticketing capacity: 600
Enter number of the tickets sold: 600

Additional data (Y/N)? N

Movie/Capacity/Tickets Sold/Seats Available
------------------------------------------------------
Mumm II/500/492/8
Meet the Parents/600/600/0


Last edited on
Topic archived. No new replies allowed.