fork download
  1. //Ryan Shahriyarpour CS1A Carl Argila Chapter 3 HW Q:6
  2. //
  3. /*****************************************************************************
  4.  *
  5.  * How Many Widgets
  6.  *
  7.  * ********************************************
  8.  *
  9.  *
  10.  * The goal is to calculate number of widgets on a pallet
  11.  *
  12.  * Widgets = (Pallet weight with widgets - empty pallet) / The widget weight
  13.  *
  14.  * ***********
  15.  *
  16.  * INPUT
  17.  * emptyWeight : weight of empty pallet
  18.  * totalWeight : weight of pallet with widgets
  19.  *
  20.  * OUTPUT
  21.  * widgets : number of widgets on pallet
  22.  *
  23.  ****************************************************************************/
  24.  
  25. #include <iostream>
  26.  
  27. int main() {
  28. double emptyWeight;
  29. double totalWeight;
  30. int widgets;
  31.  
  32. std::cout << "Enter weight of empty pallet: ";
  33. std::cin >> emptyWeight;
  34.  
  35. std::cout << "Enter weight of pallet with widgets: ";
  36. std::cin >> totalWeight;
  37.  
  38. widgets = (totalWeight - emptyWeight) / 9.2;
  39.  
  40. std::cout << "Number of widgets: " << widgets << std::endl;
  41.  
  42. return 0;
  43. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
Enter weight of empty pallet: Enter weight of pallet with widgets: Number of widgets: 0