Adding characters after the cin object

How do you add a character after the user input?
For example i have an assignment involving loan calculations and my cin looks like this

1
2
cout << "Please insert your monthly interest :" << setw(17) <<""; 
cin >> MonthlyInterest;


When the monthly interest is set at 1% and the user inputs it the command window looks like this

Please insert your monthly interest: 1

I would LIKE to have it look as the following

Please insert your monthly interest: 1%

So how can i add a "%" to directly follow the number the user inputs?
closed account (N36fSL3A)
If it is not a char* then you would do this:

1
2
3
4
5
6
//... Your cout statment....

cin << MonthlyInterest;

//Adding character
MonthlyInterest = MonthlyInterest + "%";
MonthlyInterest = MonthlyInterest + "%"; is giving me an error. the "%" segment is highlighted in red with a 'expression must have arithmetic or unscoped enum type
I executed this code:

1
2
3
4
    double MonthlyInterest;
    cout << "Please insert your monthly interest :" << setw(17) << " "; 
    cin >> MonthlyInterest;
    cout << MonthlyInterest << "%" << endl;


And I had this in a file called input.txt:

56.7

I then ran the program with the input.txt being piped into the program and it worked as you described.
closed account (N36fSL3A)
Yes, mine or kevin's examples work, use mine if you want the variable value to be changed, use kevin's if you want the variable outputed but not the value changed.
Topic archived. No new replies allowed.