Program Issues

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2005
Posts: 1
Reputation: Digital Reaver is an unknown quantity at this point 
Solved Threads: 0
Digital Reaver Digital Reaver is offline Offline
Newbie Poster

Program Issues

 
0
  #1
May 9th, 2005
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)
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 32
Reputation: sinrtb is an unknown quantity at this point 
Solved Threads: 0
sinrtb sinrtb is offline Offline
Light Poster

Re: Program Issues

 
0
  #2
May 9th, 2005
The tail end of your program makes little sense
  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
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 466
Reputation: winbatch is on a distinguished road 
Solved Threads: 18
winbatch's Avatar
winbatch winbatch is offline Offline
Posting Pro in Training

Re: Program Issues

 
0
  #3
May 9th, 2005
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...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC