Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Printing Output

Printing Output

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BRIMID
    wrote on last edited by
    #1

    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

    M D 2 Replies Last reply
    0
    • B BRIMID

      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

      M Offline
      M Offline
      Martin Koorts
      wrote on last edited by
      #2

      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

      B 1 Reply Last reply
      0
      • M Martin Koorts

        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

        B Offline
        B Offline
        BRIMID
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • B BRIMID

          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

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups