Calculating the number of pools that can be stored on a shelf, without overhang. - C++ Data Type

C++ examples for Data Type:double

Description

Calculating the number of pools that can be stored on a shelf, without overhang.

Demo Code

#include <iostream>

int main() {/*from   w  w w .  j a v  a2  s  . c o m*/
  const int inches_per_foot {12};

  double shelf_length {};
  double shelf_depth {};
  double pool_size {};

  std::cout << "Enter length (feet): ";
  std::cin >> shelf_length;

  std::cout << "Enter depth (feet): ";
  std::cin >> shelf_depth;

  std::cout << "Enter length of the side of a pool (inches): ";
  std::cin >> pool_size;

  long pools {static_cast<long>((shelf_length * inches_per_foot) / pool_size) * static_cast<long>((shelf_depth * inches_per_foot) / pool_size)};

  std::cout << "The number of pools that can be contained in a single layer is " << pools << std::endl;
}

Result


Related Tutorials