100.50 Bill Gates Vice President 35 Terry Bradshaw Secretary 42.45 Wally Cleaver Senior Vice President 23.45 James Taylor Welder 13.45 TJ McCall Senior Programmer
class Employee { private: public: float HourlyRate; string FirstName; string LastName; string Position; void fired(void); void changerate(float amount); }; void Employee::fired(void) { HourlyRate=0; cout << FirstName << " " << LastName << ", you are fired! You are currently earning $" << HourlyRate << " per hour." << endl; } void Employee::changerate(float amount) { HourlyRate+=amount; if (HourlyRate < 5.15) HourlyRate = 5.15; cout << FirstName << " " << LastName << ", you are currently earning $" << HourlyRate << " per hour." << endl; }
Hourly Wage First Name Second Name Position ----------------------------------------------------------- 100.50 Bill Gates Vice President 42.45 Wally Cleaver Senior Vice President 35.00 Terry Bradshaw Secretary 23.45 James Taylor Welder 13.45 TJ McCall Senior Programmer
For example, if you had a Product object array with MAX elements and wanted to print out its float dollaramount values in one column and string description in the second column, this code would do it for you:
for (int ii=0 ; ii<MAX ; ++ii) { cout << setiosflags( ios::fixed | ios::showpoint ) << setw(11) << setprecision(2) << Product[ii].dollaramount << " " << setw(15 - Product[ii].description.length()) << resetiosflages( ios::left ) << Product[ii].description << endl; }