//Devin Scheu CS1A Chapter 3, P. 144, #6
//
/**************************************************************
*
* CALCULATE NUMBER OF WIDGETS ON PALLET
* ____________________________________________________________
* This program calculates the number of widgets stacked on a
* pallet based on the pallet's weight with and without widgets.
* Each widget weighs 9.2 pounds.
*
* Computation is based on the formula:
* widgetCount = (totalWeight - palletWeight) / 9.2
* ____________________________________________________________
* INPUT
* palletWeight : Weight of the pallet alone (in pounds, as a double)
* totalWeight : Total weight of pallet with widgets (in pounds, as a double)
*
* PROCESSING
* widgetCount : Number of widgets stacked on the pallet (as an integer)
*
* OUTPUT
* widgetCount : The calculated number of widgets
*
**************************************************************/
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main () {
//Variable Declarations
double palletWeight; //INPUT - Weight of the pallet alone (in pounds, as a double)
double totalWeight; //INPUT - Total weight of pallet with widgets (in pounds, as a double)
int widgetCount; //PROCESSING - Number of widgets stacked on the pallet (as an integer)
//Prompt for Input
cout << "Enter the weight of the pallet alone (in pounds): ";
cin >> palletWeight;
cout << "\nEnter the total weight of the pallet with widgets (in pounds): ";
cin >> totalWeight;
//Calculate Number of Widgets
widgetCount = static_cast<int>((totalWeight - palletWeight) / 9.2 + 0.5); // Rounding to nearest integer
//Output Result
cout << fixed << setprecision(0);
cout << "\n";
cout << left << setw(25) << "Pallet Weight:" << right << setw(15) << palletWeight << " pounds" << endl;
cout << left << setw(25) << "Total Weight:" << right << setw(15) << totalWeight << " pounds" << endl;
cout << left << setw(25) << "Number of Widgets:" << right << setw(15) << widgetCount << endl;
} //end of main()