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?

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! :-)

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.

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;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.