1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
// Annual Income.cpp - displays the annual
// income without any dollar signs, commas,
// or spaces
// Created/revised by <YOUR NAME> on <current date>
// string commands used:
// getline(), length(), substr(), erase()
/* Sample Program Run
Annual income (-1 to end): $22,1234.44
Annual income with no dollar signs, commas, or spaces: 221234.44
*/
#include <iostream>
#include <string>
using namespace std;
int main()
{
// declarations
string income = "";
string currentChar = "";
unsigned int subscript = 0; //keeps track of subscripts
// statements
cout << "Annual income (-1 to end): ";
getline(cin, income);
while (income != "-1")
{
//remove dollar signs, commas, and spaces
while (subscript < income.length())
{
// STUDENT CODE BEGINS
cout << income.erase(0,2) << "??????
// STUDENT CODE ENDS
} //end while
//display annual income
cout << "Annual income with no dollar "
<< "signs, commas, or spaces: "
<< income << endl << endl;
cout << "Annual income (-1 to end): ";
getline(cin, income);
subscript = 0;
} //end while
cin.get();
return 0;
} //end of main function
|