| | |
Program Issues
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2005
Posts: 1
Reputation:
Solved Threads: 0
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)
#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)
•
•
Join Date: Apr 2005
Posts: 32
Reputation:
Solved Threads: 0
The tail end of your program makes little sense
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
C++ Syntax (Toggle Plain Text)
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)
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
![]() |
Similar Threads
- Send data on a serial port (C++)
- Computer Program Issues (C++)
- Multi-user program issues (VB.NET)
- Analyze server logs (Linux Servers and Apache)
Other Threads in the C++ Forum
- Previous Thread: Winsock Send File To Client Help
- Next Thread: Compile .cpp into .bin extension
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion count database delete deploy desktop developer directshow dll dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph homeworkhelp homeworkhelper iamthwee ifstream input int integer lib linkedlist linker linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





