Printing Output
-
I am having a problems printing the output for this program. With C++ when I compile and run the program I am left with an exe file. How do I incorporate code to print out the output? Below is the code. Where do I enter it within the program? Basically I want to be able to print the output. //#include int main() //(int,char*) //{ //ofstream printer ("1pt1:"); //Printer <<"test"<> ans; cin.ignore(); if (ans == 'A' || ans == 'a' ){ cout << "\nEnter RWA Base Estimate, then press the enter key:$\a"; cin >> input; cout << "You entered:$" << input << endl; int pos = input.find(','); while (pos != -1) { input.replace(pos, 1, ""); pos = input.find(','); } number = atoi(input.c_str()); fee = number * 0.04; cout << fixed; cout.precision(2); cout << "4% Management Fee:$" << fee <<"\n"; total = number + fee; cout << fixed; cout.precision(2); cout << "Total:$" << total <<"\n"; if (total >= 1 && total <= 2499) { cout << fixed; cout.precision(2); cout << "Overhead:$" << total*0.1 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.1) <<"\n"; } if (total >= 2500 && total <= 9999) { cout << fixed; cout.precision(2); cout << "Overhead:$" << total*0.09 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.09) <<"\n"; } if (total >= 10000 && total <= 24999) { cout << fixed; cout.precision(2); cout << "Overhead:$" << total*0.08 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.08) <<"\n"; } if (total >= 25000 && total <= 49999) { cout << fixed; cout.precision(2); cout << "Overhead:$" << total*0.07 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.07) <<"\n"; } if (total >= 50000 && total <= 99999) { cout << fixed; cout.precision(2); cout << "Overhead:$" << total*0.05 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.05) <<"\n"; } if (total >= 100000 && total <= 299999) { cout << fixed; cout.precision(2); cout << "Overhead:$" << total*0.03 <<"\n"; cout << "Total Obligation:$" << total + (tota
-
I am having a problems printing the output for this program. With C++ when I compile and run the program I am left with an exe file. How do I incorporate code to print out the output? Below is the code. Where do I enter it within the program? Basically I want to be able to print the output. //#include int main() //(int,char*) //{ //ofstream printer ("1pt1:"); //Printer <<"test"<> ans; cin.ignore(); if (ans == 'A' || ans == 'a' ){ cout << "\nEnter RWA Base Estimate, then press the enter key:$\a"; cin >> input; cout << "You entered:$" << input << endl; int pos = input.find(','); while (pos != -1) { input.replace(pos, 1, ""); pos = input.find(','); } number = atoi(input.c_str()); fee = number * 0.04; cout << fixed; cout.precision(2); cout << "4% Management Fee:$" << fee <<"\n"; total = number + fee; cout << fixed; cout.precision(2); cout << "Total:$" << total <<"\n"; if (total >= 1 && total <= 2499) { cout << fixed; cout.precision(2); cout << "Overhead:$" << total*0.1 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.1) <<"\n"; } if (total >= 2500 && total <= 9999) { cout << fixed; cout.precision(2); cout << "Overhead:$" << total*0.09 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.09) <<"\n"; } if (total >= 10000 && total <= 24999) { cout << fixed; cout.precision(2); cout << "Overhead:$" << total*0.08 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.08) <<"\n"; } if (total >= 25000 && total <= 49999) { cout << fixed; cout.precision(2); cout << "Overhead:$" << total*0.07 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.07) <<"\n"; } if (total >= 50000 && total <= 99999) { cout << fixed; cout.precision(2); cout << "Overhead:$" << total*0.05 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.05) <<"\n"; } if (total >= 100000 && total <= 299999) { cout << fixed; cout.precision(2); cout << "Overhead:$" << total*0.03 <<"\n"; cout << "Total Obligation:$" << total + (tota
Hi What happens if you run this code; ofstream printer("lpt1:"); printer << "test" << endl; If that prints something on your printer, you're in business and can simply change all instances of 'cout' to 'printer', with above lines added at beginning of the main function. HTH Martin
-
Hi What happens if you run this code; ofstream printer("lpt1:"); printer << "test" << endl; If that prints something on your printer, you're in business and can simply change all instances of 'cout' to 'printer', with above lines added at beginning of the main function. HTH Martin
Thanks Martin, I will try your recommendation and see what happens. I did not know you had to change all couts to printer. I am a beginner and have been working with this for awhile. I have had many recommendations and probably due to my inexperience I was not able to figure out what was going on.
-
I am having a problems printing the output for this program. With C++ when I compile and run the program I am left with an exe file. How do I incorporate code to print out the output? Below is the code. Where do I enter it within the program? Basically I want to be able to print the output. //#include int main() //(int,char*) //{ //ofstream printer ("1pt1:"); //Printer <<"test"<> ans; cin.ignore(); if (ans == 'A' || ans == 'a' ){ cout << "\nEnter RWA Base Estimate, then press the enter key:$\a"; cin >> input; cout << "You entered:$" << input << endl; int pos = input.find(','); while (pos != -1) { input.replace(pos, 1, ""); pos = input.find(','); } number = atoi(input.c_str()); fee = number * 0.04; cout << fixed; cout.precision(2); cout << "4% Management Fee:$" << fee <<"\n"; total = number + fee; cout << fixed; cout.precision(2); cout << "Total:$" << total <<"\n"; if (total >= 1 && total <= 2499) { cout << fixed; cout.precision(2); cout << "Overhead:$" << total*0.1 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.1) <<"\n"; } if (total >= 2500 && total <= 9999) { cout << fixed; cout.precision(2); cout << "Overhead:$" << total*0.09 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.09) <<"\n"; } if (total >= 10000 && total <= 24999) { cout << fixed; cout.precision(2); cout << "Overhead:$" << total*0.08 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.08) <<"\n"; } if (total >= 25000 && total <= 49999) { cout << fixed; cout.precision(2); cout << "Overhead:$" << total*0.07 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.07) <<"\n"; } if (total >= 50000 && total <= 99999) { cout << fixed; cout.precision(2); cout << "Overhead:$" << total*0.05 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.05) <<"\n"; } if (total >= 100000 && total <= 299999) { cout << fixed; cout.precision(2); cout << "Overhead:$" << total*0.03 <<"\n"; cout << "Total Obligation:$" << total + (tota
From a command prompt, redirect the output of your program to the printer by typing:
program > prn
BTW, for future posts, there is no need to post all of your code, only the relevant parts. Asking folks to wade through a bunch of code is a sure-fire recipe for getting little to no help.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow