here you go. see the comments for why it was wrong... take note: the way I did it cuts out the printing that you wanted. I suspect that non-standard coding was your biggest problem...
Code:
//This program written by Dan Kemper
//This program will balance your checkbook and print the results to a textfile named "checkbook.txt" or print the scrren to your printer
//Suggestions and other comments can be sent to my email: [email protected]
#include <iostream> //don't use the .h headers
#include <fstream> //and there's no space between
#include <iomanip> //the '#' and include
using namespace std; //required with the new headers
int main ()
{
//Declares variables
char FirstName[20];
char LastName[30];
char Account[9];
int PrintStatement;
float Balance;
float Deposits;
float Withdrawls;
float NewBalance;
//Makes Textfile
//if you want to MAKE the text file, you should explicitly say so with
//the 'ios::trunc' argument. that clears out whatever was there before
//and starts fresh. I changed it to test.out for my own purposes.
ofstream outfile ("test.out",ios::trunc);
//Outputs to screen
cout << " AAA TTTTTTTTTTTTTTT MMMMM MMMMM\n";
cout << " AAAAA TTTTTTTTTTTTTTT MMMMMM MMMMMM\n";
cout << " AAA AAA TTTTTT MMM MMM MMM MMM\n";
cout << " AAA AAA TTTTTT MMM MMM MMM MMM\n";
cout << " AAAAAAAAAAA TTTTTT MMM MMM MMM MMM\n";
cout << " AAAAAAAAAAAAA TTTTTT MMM MMM MMM MMM\n";
cout << " AAA AAA TTTTTT MMM MMM MMM MMM\n";
cout << "AAA AAA TTTTTT MMM MMMMM MMM\n";
//system("PAUSE"); //don't use this - nonstandard and possibly dangerous
//the following is a better alternative:
cout<<"press [ENTER] to continue...\n";
cin.get();
cout << "\n\nThis program balances your checkbook.\n\n";
cout << "First Name: ";
//Asks user for input
cin.get(FirstName, 20);
cin.ignore(80, '\n');
cout << "Last Name: ";
cin.get(LastName, 30);
cin.ignore(80, '\n');
cout << "Account number: ";
cin.get(Account, 9);
cin.ignore(80, '\n');
cout << "\n\nStatement balance: ";
cin >> Balance;
cin.ignore(1); //clean up after cin
cout << "\nOutstanding deposits: ";
cin >> Deposits;
cin.ignore(1); //see previous
cout << "\nOutstanding withdrawls: ";
cin >> Withdrawls;
cin.ignore(1); //again
//Conversions
NewBalance = Balance + Deposits - Withdrawls;
//Output Results
cout << "\nNew balance: ";
cout << setiosflags (ios::fixed) << setprecision(2) << NewBalance;
cout << "\n\nPrint? (Y/N)\n";
cin >> PrintStatement;
cin.ignore(1); //see above statements
/* this entire section is non-standard and doesn't make sense. see comments
*
* FYI: there's no way to print using standard C++ - but if you're in windows,
* you may want to ask help with that - it's a more advanced topic.
*
do
{
while (PrintStatement=='y' || PrintStatement=='Y')
{
system("PRINT"); //non-standard and possibly dangerous
cout << "Thank You!";
//getch (); //non-standard function
return 0;
}
else //there is no if for this else - what were you trying to do?
{
cout << "Thank You! You may see your statement in a textfile named 'checkbook.txt'.";
}
} //is this a do-while loop? if so, where's the while?
*/
//Prints to Textfile
outfile << "Name: " << FirstName << " " << LastName << "\n";
outfile << "Account Number: " << Account << "\n";
outfile << "Statement Balance: " << Balance << "\n";
outfile << "Outstanding Deposits: " << Deposits << "\n";
outfile << "Outstanding Withdrawls: " << Withdrawls << "\n";
outfile << "New Balance: " << setiosflags (ios::fixed) << setprecision(2) << NewBalance;
outfile.close(); //close your files.
//Stops program until button is pressed
//getch(); //again, don't use this
cin.get(); //this is much better
return 0;
}