#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
struct Product
{
string name;
double sales;
};
inline void print( const Product& v)
{
cout << fixed << setprecision(2)
<< left << setw(20) << v.name
<< right << setw(10) << v.sales << endl;
}
int main()
{
Product productObject, productObject2;
productObject.name = "one";
productObject.sales = 37.37;
productObject2.name = "two";
productObject2.sales = 231.23;
productObject.sales += 17.11;
cout << " Product Sales\n"
<< endl;
print( productObject);
print( productObject2);
cout << "\nTotal of sales: "
<< productObject.sales + productObject2.sales << endl;
Product *ptr = &productObject2;
if( productObject2.sales < productObject.sales)
ptr = &productObject;
cout << "\nSalesman of the month: " << ptr->name << endl;
return 0;
}
|