944,030 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1545
  • C++ RSS
May 9th, 2005
0

Program Issues

Expand Post »
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)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Digital Reaver is offline Offline
1 posts
since May 2005
May 9th, 2005
0

Re: Program Issues

The tail end of your program makes little sense
C++ Syntax (Toggle Plain Text)
  1. if (char; Y = Y );
  2. {
  3. ofstream myFile("c:/reciet.txt");
  4. // Creates an ofstream object named myFile
  5.  
  6. if (! myFile) // Always test to see if the file open
  7. {
  8. cout << "Error opening output file" << endl;
  9. return -1;
  10. }
  11.  
  12. myFile << cout << endl; //prints hello world to the out.txt file
  13.  
  14. myFile.close(); //closes the file
  15. 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
Last edited by sinrtb; May 9th, 2005 at 6:48 am. Reason: fixed code tag
Reputation Points: 10
Solved Threads: 0
Light Poster
sinrtb is offline Offline
32 posts
since Apr 2005
May 9th, 2005
0

Re: Program Issues

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...
Reputation Points: 68
Solved Threads: 18
Posting Pro in Training
winbatch is offline Offline
466 posts
since Feb 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Winsock Send File To Client Help
Next Thread in C++ Forum Timeline: Compile .cpp into .bin extension





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC