Thousands Sepearator
-
This is tne final step in my program and I cannot figure it out. Where do I enter the line with the slashes next to them? I changed the number to amount in the program. In the posoiton they are in I get 19 errors.Below is what was given: string input; int number; int pos = input.find(','); while (pos != -1) { ////input.replace(pos, 1, ""); ////pos = input.find(','); } number = atoi(input.c_str()); cout << number<< endl; This is what I done. int main() { int c; float fee; double total; char a ='y', ans; ////string input; //// int amount; while(a =='y'|| a =='Y') { cout << "\nChoose from options below.\n"; cout << "\nEnter A to calculate total RWA cost.\n"; cout << "\nEnter B to calculate RWA base estimate.\n"; cout << "\n\t\tEnter your choice, then press the enter key:"; cin >> ans; cin.ignore(); if (ans == 'A' || ans == 'a' ){ cout << "\nEnter RWA Base Estimate, then press the enter key:$"; cin >> amount; ////int pos = input.find(','); ////while (pos != -1) ////{ ////input.replace(pos, 1, ""); ////pos = input.find(','); ////} ////amount = atoi(input.c_str()); ////cout << amount<< endl; cout << fixed; cout.precision(2); fee = amount * 0.04; cout << "4% Management Fee:$" << fee <<"\n"; total = amount + fee; cout << fixed; cout.precision(2); cout << "Total:$" << total <<"\n";
-
This is tne final step in my program and I cannot figure it out. Where do I enter the line with the slashes next to them? I changed the number to amount in the program. In the posoiton they are in I get 19 errors.Below is what was given: string input; int number; int pos = input.find(','); while (pos != -1) { ////input.replace(pos, 1, ""); ////pos = input.find(','); } number = atoi(input.c_str()); cout << number<< endl; This is what I done. int main() { int c; float fee; double total; char a ='y', ans; ////string input; //// int amount; while(a =='y'|| a =='Y') { cout << "\nChoose from options below.\n"; cout << "\nEnter A to calculate total RWA cost.\n"; cout << "\nEnter B to calculate RWA base estimate.\n"; cout << "\n\t\tEnter your choice, then press the enter key:"; cin >> ans; cin.ignore(); if (ans == 'A' || ans == 'a' ){ cout << "\nEnter RWA Base Estimate, then press the enter key:$"; cin >> amount; ////int pos = input.find(','); ////while (pos != -1) ////{ ////input.replace(pos, 1, ""); ////pos = input.find(','); ////} ////amount = atoi(input.c_str()); ////cout << amount<< endl; cout << fixed; cout.precision(2); fee = amount * 0.04; cout << "4% Management Fee:$" << fee <<"\n"; total = amount + fee; cout << fixed; cout.precision(2); cout << "Total:$" << total <<"\n";
You have everything in the correct place. Just change the line
cin >> amount;
to
cin >> input;
I ran the code as posted here (added missing closing braces) and it ran fine.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!