Advertisement
desislava_topuzakova

08.FishTank

Jan 16th, 2021
1,068
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     //0. вход
  7.     //1. обем на аквариума = дължина * широчина * височина -> куб. см
  8.     //2. превръщаме обема от куб. см към литри
  9.     //3. обем на заетата част -> процент е зает -> процент в число -> / 100 или * 0.01
  10.     //4. обем на свободната част = обем в литри * (1 - процент в число)
  11.  
  12.     int lenght, width, height;
  13.     cin >> lenght >> width >> height;
  14.     double percent;
  15.     cin >> percent;
  16.  
  17.     int volume = lenght * width * height; //куб.см
  18.     double volumeLiters = volume * 0.001; //куб.см / 1000 -> литри
  19.     double numberPercent = percent / 100; //* 0.01
  20.  
  21.     double volumeFreeSpace = volumeLiters * (1 - numberPercent);
  22.  
  23.     cout.setf(ios::fixed);
  24.     cout.precision(2);
  25.  
  26.     cout << volumeFreeSpace << endl;
  27.  
  28.  
  29.  
  30. }
  31.  
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement