|
|
|
|
|
|
|
// && deptSales == sum of the sales values for the department
{
int numDays; // Number of business days in the month
int day; // Loop control variable for reading daily sales
float sale; // One day's sales for the department
dataFile >> deptID;
if ( !dataFile ) // Check for normal EOF
return;
dataFile >> numDays;
if ( !dataFile ) // Data validation test
{
cout << Data error: No data following dept. ID. << endl;
return;
}
deptSales = 0.0;
day = 1; // Initialize loop control variable
while (day <= numDays)
{
dataFile >> sale;
if ( !dataFile ) // Data validation test
{
cout << Data error: Ran out of data in mid-set.
<< endl;
return;
}
deptSales = deptSales + sale;
day++; // Update loop control variable
}
}
//******************************************************************
void PrintData( /* in */ int deptID, // Department ID number
/* in */ int storeNum, // Store number
/* in */ float deptSales ) // Total sales for the
// department
// Prints the department ID number, the store number, and a
// bar graph of the sales for the department. The bar graph
// is printed at a scale of one mark per $500
// Precondition:
// deptID contains a valid department number
// && storeNum contains a valid store number
// && 0.0 <= deptSales <= 25000.0
|
|
|
|
|
|