C++ Movie Kiosk Project

Hello all. I need some help with this program. Here are the requirements:
I want a kiosk style system for my movie theater.
I want customers to be able to purchase movie
tickets and/or food/drink items from this kiosk.

The customer will get a receipt he/she can bring
to get food/drink items, and also ticket for
any movie he/she wants to see.

The program should have one total that the customer
would pay when the customer is finished using
the kiosk:

example: I buy 2 movies tickets for a particular
movie and also buy 2 popcorns and 2 drinks.

Ideally, I would have a combo package where a
customer can have purchase tickets, food/drink
items for a discount.

The kiosk will accept credit cards only, therefore
you do not need to worry payment code in your
program


What I am looking for in your program:
Files for reading/displaying the available movies
Functions: should have functions for the movie
section, and also for food/drink items.



Here is the code I have so far:
#include<iostream>
#include<iomanip>
#include<fstream>
#include<string>

using namespace std;

int mpick(ifstream &iFile, string movie[])
{
int x=0;
while(iFile.good())
{
iFile >> movie[x];
x++;
}
return x;

}


double totalprice(string movie[], double total)
{
double number;
char selection;
int x=0;
for(int a=0;a<=3;a++)
{
cout << "All Movies are $6.99 per ticket." << endl;
cout << "Choose from the movies above:" << endl;

cin >> movie[x];
cout << "How many tickets for that movie: " << endl;
cin >> number;
total=6.99*number;
cout << "Would you like to purchase another movie? (Y or N)";
cin >> selection;
}



cout << "Total Price for movie tickets:$ " << total << endl;

return total;
}




int main()
{
const int x=100;
string movie[x];
char selection;
double number;
double movieCost=6.99;
double total=1;
int v;

ifstream iFile;
ofstream oFile;
iFile.open("input.txt");
v=mpick(iFile,movie);
cout << fixed << showpoint << setprecision(2);
oFile << fixed << showpoint << setprecision(2);

cout << "Would you like to see a movie today? (Y or N)";
cin >> selection;
cout << endl;
while(selection == 'y' || selection == 'Y')
{
for(int b=0;b<v;b++)
cout << movie[b] << endl;
totalprice(movie,total);






}
if(selection == 'n' || selection == 'N')
{
cout << "Do you want any refreshments? (Y or N)";
cin >> selection;
cout << endl;

if(selection == 'y' || selection == 'Y')
{
cout << "Choose fromt the choices below: " << endl;
}
}

else
cout << "Do you want any refreshments? (Y or N)";
cin >> selection;
cout << endl;

if(selection == 'y' || selection == 'Y')
{
cout << "Choose fromt the choices below: " << endl;
}





system("pause");
return 0;
}


Ok so I know I do not have the refreshments menu in there but if I can get the movie list to work it will just be a rinse and repeat sort of thing.

My problem with this code is that for one the movie list is not reading from my file the second time I try to purchase a movie ticket. The first time it goes through the loop it list all of the movies but the times after that it does not display. Also, When I get done selecting my movies and I select 'N' to escape the loop it stays in the loop. Can someone shed some light onto this issue or maybe add some code to my program to get me back up and running. I have spent much time trying to fix it and am pulling my hair out. And yes I know this is probably a simple project to most of you, but this is my first programming class ever so cut me some slack. Thanks!!
I was working on the code a little...
code:
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
using namespace std;

string addmovie, removemovie, movietitle;
vector<string> movieList,snackList, drinkList;
vector<string>::iterator movieIter,snackIter, drinkIter;
const double movieCost=6.99;
char selection;
int x=0;
double number, total;
ifstream upload;

void snackinput() ///Edit what the snacks are here
{
snackList.push_back("Skittles");
snackList.push_back("twislers");
snackList.push_back("m&m's");
snackList.push_back("Nerds");
snackList.push_back("Laughy taffy");
snackList.push_back("gum drops");
}
void snackpick() ///Picking snacks code
{
cout<<"Do you want any snacks? (Y or N)\n> ";
cin>>selection;
cout<<endl;
if(selection == 'y' || selection == 'Y'){
cout<<" We currently have in stock:"<<endl;
snackIter = snackList.begin();
while(x!=snackList.size()-1){
cout<<" "<<*snackIter<<",";
++snackIter;
x++;}
cout<<"and "<<*snackIter<<endl;
cout<<""<<endl;


}}
void drinkinput() ///Edit what the drinks are here
{
drinkList.push_back("Coca-Cola");
drinkList.push_back("Sprite");
drinkList.push_back("Pepsi");
drinkList.push_back("Rootbeer");
drinkList.push_back("Fanta");
drinkList.push_back("Water");
drinkList.push_back("Hi-C");
}
void drinkpick() ///Picking drinks code
{
cout << "Do you want any drinks? (Y or N)\n> ";
cin >> selection;
cout << endl;
if(selection == 'y' || selection == 'Y'){
cout<<"We currently have: "<<endl;
drinkIter = drinkList.begin();
x=0;
while(x!=drinkList.size()-1){
cout<<" "<<*drinkIter<<",";
++drinkIter;
x++;}
cout<<"and "<<*drinkIter<<endl;




}}
void refreshmentsbuy() ///code for buying the refreshments
{

}
void movieupload() ///go to the movies.txt file to change the movies. *Remember to put a ':' as the first thing and after each movie*
{
upload.open("movies.txt");
while(getline(upload,removemovie,':')){
upload>>addmovie;
movieList.push_back(addmovie);
sort(movieList.begin(), movieList.end());
cin.clear();
cin.sync();}
}
void moviepick() ///Picking movies code
{
cout<<"\n Your movie options are:\n";
movieIter = movieList.begin();
int x=0;
while(x!=movieList.size()-1){
cout<<" "<<*movieIter<<",";
++movieIter;
x++;}
cout<<"and "<<*movieIter;
cout<<endl<<"What will you choose?"<<endl;
cin>>movietitle;
}
void moviedisplay()
{

}
int main()
{
cout<<"Would you like to see a movie today? (Y or N)\n> ";
cin>>selection;
if(selection == 'y' || selection == 'Y'){
cout << "All Movies are $6.99 per ticket." << endl;
cout << "How many tickets for your movie: " << endl;
cin >> number;
total=movieCost*number;
cout << "Total Price for movie tickets: $" << total << endl;
cout<<"Please pay with your Credit/Debit Card"<<endl<<endl;

snackinput();
snackpick();
drinkinput();
drinkpick();
refreshmentsbuy();
movieupload();
moviepick();
moviedisplay();}
cin.get();
return 0;
}
Last edited on
Thank you for your input. Unfortunately we have not gone over #include <vector>, #include <algorithm> or #include <iterator> so I cannot use these for my code. This is a basic c++ class and can only use the libraries that I included in my code that I gave. I wish we could use others but not right now.
what you can do is myfile>> VecString
Move the data from the file in to the Vector<string>
Topic archived. No new replies allowed.