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. C++ Help

C++ Help

Scheduled Pinned Locked Moved C / C++ / MFC
c++helptutorial
3 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

    Code does math calculations twice, gives exponential when amount is 1,000,000 and does not exit when n is entered for continuance. I would also like to know how to create this so the person using it could print the output. // RWA's and Charges #include using std::cout; using std::cin; using namespace std; //using::endl; int main() { int choice, c; float amount,total,fee; char choice3 ='y'; while(choice3=='y'|| choice3=='Y') { cout << "\nChoose from options below.\n"; cout << "\nEnter 1 to calculate total RWA cost.\n"; cout << "\nEnter 2 to calculate RWA base estimate.\n"; cout << "\n\t\tEnter your choice, then press the enter key:"; cin >> choice; if (choice == 1){ cout << "\nEnter RWA Base Estimate, then press the enter key:$"; cin >> amount; fee = amount * 0.04; cout << "4% Management Fee:$" << fee <<"\n"; total = amount + fee; cout << "Total:$" << total <<"\n"; if (total >= 1 && total <= 2499 ||total >= 1 && total <= 2,499) { cout << "Overhead:$" << total*0.1 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.1) <<"\n"; } if (total >= 2500 && total <= 9999 ||total >= 2,500 && total <= 9,999 ) { cout << "Overhead:$" << total*0.09 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.09) <<"\n"; } if (total >= 10000 && total <= 24999 ||total >= 10,000 && total <= 24,999) { cout << "Overhead:$" << total*0.08 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.08) <<"\n"; } if (total >= 25000 && total <= 49999 ||total >= 25,000 && total <= 49,999) { cout << "Overhead:$" << total*0.07 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.07) <<"\n"; } if (total >= 50000 && total <= 99999 ||total >= 50,000 && total <= 99,999 ) { cout << "Overhead:$" << total*0.05 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.05) <<"\n"; } if (total >= 100000 && total <= 299999 ||total >= 100,000 && total <= 299,999) { cout << "Overhead:$" << total*0.03 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.03) <<"\n"; } if (total >= 300000 && total <= 999999 ||total >= 300,000 && total <= 999,999) { cout << "Overhead:$" << total*

    M R 2 Replies Last reply
    0
    • B BRIMID

      Code does math calculations twice, gives exponential when amount is 1,000,000 and does not exit when n is entered for continuance. I would also like to know how to create this so the person using it could print the output. // RWA's and Charges #include using std::cout; using std::cin; using namespace std; //using::endl; int main() { int choice, c; float amount,total,fee; char choice3 ='y'; while(choice3=='y'|| choice3=='Y') { cout << "\nChoose from options below.\n"; cout << "\nEnter 1 to calculate total RWA cost.\n"; cout << "\nEnter 2 to calculate RWA base estimate.\n"; cout << "\n\t\tEnter your choice, then press the enter key:"; cin >> choice; if (choice == 1){ cout << "\nEnter RWA Base Estimate, then press the enter key:$"; cin >> amount; fee = amount * 0.04; cout << "4% Management Fee:$" << fee <<"\n"; total = amount + fee; cout << "Total:$" << total <<"\n"; if (total >= 1 && total <= 2499 ||total >= 1 && total <= 2,499) { cout << "Overhead:$" << total*0.1 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.1) <<"\n"; } if (total >= 2500 && total <= 9999 ||total >= 2,500 && total <= 9,999 ) { cout << "Overhead:$" << total*0.09 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.09) <<"\n"; } if (total >= 10000 && total <= 24999 ||total >= 10,000 && total <= 24,999) { cout << "Overhead:$" << total*0.08 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.08) <<"\n"; } if (total >= 25000 && total <= 49999 ||total >= 25,000 && total <= 49,999) { cout << "Overhead:$" << total*0.07 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.07) <<"\n"; } if (total >= 50000 && total <= 99999 ||total >= 50,000 && total <= 99,999 ) { cout << "Overhead:$" << total*0.05 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.05) <<"\n"; } if (total >= 100000 && total <= 299999 ||total >= 100,000 && total <= 299,999) { cout << "Overhead:$" << total*0.03 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.03) <<"\n"; } if (total >= 300000 && total <= 999999 ||total >= 300,000 && total <= 999,999) { cout << "Overhead:$" << total*

      M Offline
      M Offline
      Mike Danberg
      wrote on last edited by
      #2

      Assuming you mean printing the output on a printer, I would suggest looking in the articles under the Printing section. I've never done any printing outside of an MFC app, so I can't help you much. There may be some easy way of printing from a console, but I couldn't tell you what it is. The articles provide some good starting points, but judging from the simplicity of your application its probably more work than its worth.

      1 Reply Last reply
      0
      • B BRIMID

        Code does math calculations twice, gives exponential when amount is 1,000,000 and does not exit when n is entered for continuance. I would also like to know how to create this so the person using it could print the output. // RWA's and Charges #include using std::cout; using std::cin; using namespace std; //using::endl; int main() { int choice, c; float amount,total,fee; char choice3 ='y'; while(choice3=='y'|| choice3=='Y') { cout << "\nChoose from options below.\n"; cout << "\nEnter 1 to calculate total RWA cost.\n"; cout << "\nEnter 2 to calculate RWA base estimate.\n"; cout << "\n\t\tEnter your choice, then press the enter key:"; cin >> choice; if (choice == 1){ cout << "\nEnter RWA Base Estimate, then press the enter key:$"; cin >> amount; fee = amount * 0.04; cout << "4% Management Fee:$" << fee <<"\n"; total = amount + fee; cout << "Total:$" << total <<"\n"; if (total >= 1 && total <= 2499 ||total >= 1 && total <= 2,499) { cout << "Overhead:$" << total*0.1 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.1) <<"\n"; } if (total >= 2500 && total <= 9999 ||total >= 2,500 && total <= 9,999 ) { cout << "Overhead:$" << total*0.09 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.09) <<"\n"; } if (total >= 10000 && total <= 24999 ||total >= 10,000 && total <= 24,999) { cout << "Overhead:$" << total*0.08 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.08) <<"\n"; } if (total >= 25000 && total <= 49999 ||total >= 25,000 && total <= 49,999) { cout << "Overhead:$" << total*0.07 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.07) <<"\n"; } if (total >= 50000 && total <= 99999 ||total >= 50,000 && total <= 99,999 ) { cout << "Overhead:$" << total*0.05 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.05) <<"\n"; } if (total >= 100000 && total <= 299999 ||total >= 100,000 && total <= 299,999) { cout << "Overhead:$" << total*0.03 <<"\n"; cout << "Total Obligation:$" << total + (total * 0.03) <<"\n"; } if (total >= 300000 && total <= 999999 ||total >= 300,000 && total <= 999,999) { cout << "Overhead:$" << total*

        R Offline
        R Offline
        RYU
        wrote on last edited by
        #3

        Have you tried to use cin.ignore() after getting the input from keyboard (especially number/decimal)? eg. cin >> choice; cin.ignore(); Cheers... :) Samin Thomas

        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