Advertisement
tranerius

3. Футы в дюймы и наоборот

Dec 11th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 KB | None | 0 0
  1. #include <iostream>
  2. int main() {
  3.     char x, a; double f, i, r;
  4.     std::cout << "If you want to conversion of foots in inches then write f" << "\n" << "If you want to conversion of inches in foots then write i" << std::endl;
  5.     do {
  6.         while (true) {
  7.             std::cout << "What operation do you want to do ? " << std::endl;
  8.             std::cin >> x;
  9.             if (x == 'i' || x == 'f') { break; }
  10.             else {
  11.                 std::cout << "You didn't enter operation. Try again." << std::endl;
  12.                 continue;
  13.             }
  14.         }
  15.         if (x == 'f') {
  16.             std::cout << "How many foots?" << std::endl;
  17.             std::cin >> f;
  18.             r = f * 12;
  19.             std::cout << "In " << f << " foots " << r << " iches" << std::endl;
  20.         }
  21.         else if (x == 'i') {
  22.             std::cout << "How many iches?" << std::endl;
  23.             std::cin >> i;
  24.             r = i / 12;
  25.             std::cout << "In " << i << " iches " << r << " foots" << std::endl;
  26.         }
  27.         while (true) {
  28.             std::cout << "Continue? (y or n)" << std::endl;
  29.             std::cin >> a;
  30.             if (a == 'y' || a == 'n') {break;}
  31.             else {
  32.                 std::cout << "You didn't answer. Try again." << std::endl;
  33.                 continue;
  34.             }
  35.         }
  36.     } while (a == 'y' || a!='n');
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement