I created a file with notepad and named it BoxOfficeReport.txt. in it I typed
"A Movie title"
382
127
It compiles but when i run it i get something like this
Name of the movie: y(arrow type sybol)B
adult tickets sold: 4270931
children's tickets sold: 0
can anyone help.
Expand|Select|Wrap|Line Numbers
- #include <iostream>
- #include <iomanip>
- #include <fstream>
- using namespace std;
- int main()
- {
- ifstream inFile;
- const int SIZE = 25;
- char movie[SIZE];
- int adult = 6;
- int children = 3;
- int gross_profit, net_profit, distributor, aticket, cticket;
- inFile.open("BoxOfficeReport.txt");
- inFile >> movie;
- cout << "Name Of The Movie: " << movie << endl;
- inFile >> aticket;
- cout << "Adult Tickets Sold: " << aticket << endl;
- inFile >> cticket;
- cout << "Children's Tickets Sold: " << cticket << endl;
- gross_profit = (aticket*adult)+(cticket*children);
- net_profit = gross_profit * .20;
- distributor = gross_profit * .80;
- cout << "Gross Box Office Profit: " << gross_profit << endl;
- cout << "Net Box Office Profit: " << net_profit << endl;
- cout << "Amount Paid to Distributor: " << distributor << endl;
- inFile.close();
- return 0;
- }