0

i'm writing a cashier like program and i need help with the setfill code. i wrote "cout << "Item Cost: " << setw(8) << cost << setw(10) << setfill('=') << endl;" and the result is "Change Due: ======5" I want the equal sign to be on the next line all by itself. How do i write the code for it?

3
Contributors
3
Replies
25
Views
4 Years
Discussion Span
Last Post by wids101
0

Well, you are 1/2 the way there. You haven't computed the change, and just output the cost. A bit more effort and you will solve this! :-)

0

i wrote "cout << "Item Cost: " << setw(8) << cost << setw(10) << setfill('=') << endl;" and the result is "Change Due: ======5"

Impossible. If you write "item cost" how is that changed to "change due" ?? I think you misquoted something. It's best if you just copy and paste the code into DaniWeb's editor.

0
int cost;
int paid;
int change;


cout << "Enter the amount cost: ";
cin >> cost;


cout << "Enter the amount paid: ";
cin >> paid;

change = paid - cost;



cout << "Amount Paid: " << setw(8) << paid << endl; 
cout << "Item Cost: " << setw(10) << cost << endl;
cout << setfill('=') << setw(20) << "=" << endl;
cout << "Change Due: " << setw(9) << change << endl;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.