C++ static_cast to long

Description

C++ static_cast to long

#include <iostream>

int main() {//w  w  w .  j av  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;
}



PreviousNext

Related