Advertisement
JOHNYTHEWINNER

C++, Problem 7 - Fish Tank

Jan 22nd, 2020
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. # include <iostream>
  2. using namespace std;
  3. #include <iomanip>
  4.  
  5. int main()
  6. {
  7.     int lenght;
  8.     do
  9.     {
  10.         cin.clear();
  11.         cin >> lenght;
  12.     }
  13.     while (cin.bad() || lenght <10 || lenght > 500);
  14.     int width;
  15.     {
  16.         cin.clear();
  17.         cin >> width;
  18.     }
  19.     while (cin.bad() || width < 10 || width > 300);
  20.     int height;
  21.     do
  22.     {
  23.         cin.clear();
  24.         cin >> height;
  25.     }
  26.     while (cin.bad() || height < 10 || height > 500);
  27.     double percent;
  28.     do
  29.     {
  30.     cin.clear(); cin >> percent;
  31.     }
  32.     while (cin.bad() || percent < 0 || percent > 100);
  33.     double capacity = (lenght * width * height) * 0.001;
  34.     double free = (capacity - (capacity * percent / 100));
  35.     cout << fixed << setprecision(3) << free << endl;
  36.     return 0;
  37.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement