954,498 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Program Issues

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


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)

Digital Reaver
Newbie Poster
1 post since May 2005
Reputation Points: 10
Solved Threads: 0
 

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

sinrtb
Light Poster
32 posts since Apr 2005
Reputation Points: 10
Solved Threads: 0
 

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...

winbatch
Posting Pro in Training
466 posts since Feb 2005
Reputation Points: 68
Solved Threads: 18
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You