I need help writing this program i have everthing set up except i cannot get the program to save the output from it. Here is a copy of my work (It will most likely suck Im new at this sorry.) Any help will be very appreciated. I need the file to loop over again should they need to buy tickets for another movie.

#include <iostream>
#include <cstdlib>
#include <fstream>



using namespace std;


int main() //the program starts here
{


cout << "Tonights Showing\n\n\n\n";
cout << "1.Attack of the C++ Programmers\n\n";
cout << "2.Bits and Bytes\n\n";
cout << "3.Killer Coding Ninja Monkeys\n\n";
cout << " Please Enter the number of the Movie\n\n";


int a;
cin >> a;


cout << "Please Enter the number of adult tickets please.\n\n";
int b;
cin >> b;


int z;
z = b * 2;


cout << "Please Enter the number of children Tickets.\n\n";
int c;
cin >> c;


int t;
t = z + c;


cout << " Does this Complete your order. Y or N.\n\n";
char Y;
cin>> Y;


cout<< " Thank you for your support!  Your order will be displayed below.\n\n";
cout<< "Your movie you choose was";
cout<<" ";
cout<< a;
cout<<"\n\n";


cout<<"Age Group";
cout<<"  |  ";
cout<<"Number of Tickets";
cout<<"  |  ";
cout<<"Current Price Scheme";
cout<<"  |  ";
cout<<"Subtotal";
cout<<"\n";


cout<< "--------------------------------------------------------------\n";


cout<< "Child Viewing";
cout<<" ";
cout<< c;
cout<< " ";
cout<<" $1.00";
cout<<" ";
cout<< "$";
cout<< c;
cout<< "\n";


cout<<"Adult Viewing";
cout<<" ";
cout<< b;
cout<<" ";
cout<<"$2.00";
cout<<" ";
cout<< "$";
cout<< z;
cout<<"\n";


cout<< "--------------------------------------------------------------\n\n";
cout<< "Your Total is";
cout<<" ";
cout<<"$";
cout<< t;
cout<<"\n\n";


if (char; Y = Y );
{
ofstream myFile("c:/reciet.txt");
// Creates an ofstream object named myFile


if (! myFile) // Always test to see if the file open
{
cout << "Error opening output file" << endl;
return -1;
}


myFile << cout << endl;  //prints hello world to the out.txt file


myFile.close();  //closes the file
while( char Y < N)

Edited 3 Years Ago by happygeek: fixed formatting

The tail end of your program makes little sense

if (char; Y = Y );
{
ofstream myFile("c:/reciet.txt");
// Creates an ofstream object named myFile

if (! myFile) // Always test to see if the file open
{
cout << "Error opening output file" << endl;
return -1;
}

myFile << cout << endl; //prints hello world to the out.txt file

myFile.close(); //closes the file
while( char Y < N)

if (char; Y = Y );
what is it youre trying to do with that. Your if statement has no closing bracket neither does main.
Also you are never changing Y in
while( char Y < N)
N does not exist in your code. you might trying something like declaring char ans; then cin >> ans; then while ( ans == Y)
or something along those lines

When checking for equality on single characters, you should be comparing the variable against something in single quotes, for example:


if ( Y == 'Y' )

You also should not specify the word char when doing the comparison - it's datatype is known already...

This article has been dead for over six months. Start a new discussion instead.