Hey i have this homework problem that i can't seem to solve.

i have already did the rest of the program but i have to change the output of this program but i can't seem to make it work.

the output they want is..

Home Owner Price of Home Seller's Cost Agent's Commission

(assuming that the user entered 100000 for the price of the house)

this is what i had:
#include <iostream>
#include <iomanip>

cout << left;

cout << setw(10) << "Home Owner"
<< setw(10) << "Price of Home"
<< setw(10) << "Seller's Cost"
<< setw(10) << "Agent's Commission"
<< endl;

cout << right;
cout << setfill('*')
cout << fixed << showpoint

cout << setprecision(2)
cout << setw(10) << seller
<< setw(10) << price
<< setw(10) << cost
<< setw(10) << commission
<< endl;

thank-you in advance

Please use code tags. Also, what is the current (incorrect) output? Also, you don't seem to show where seller, cost etc are defined and given values?

setw(10) << "Agent's Commission".....

Your problem is in your setw(). Width is set to 10 characters but "Agent's Commission" is like 18 characters..... which beats the point of putting setw(10) in there doesn't it? Set the width so that the output actually fits in the width because right now your columns are too small so your formatting gets messed up. You'll probably want to set variable width columns depending on the size of the columns title.

cout << setfill('*')
cout << fixed << showpoint

.... where's the ";" at the end of the line?? =P

Edited 7 Years Ago by necrolin: n/a

This article has been dead for over six months. Start a new discussion instead.