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
Garcia*****100000.00*******6000.00**********1500.00

(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.unsetf(ios::left)
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

Recommended Answers

All 3 Replies

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?

Over my head. Sorry I can't help:(

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.

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

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

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.