Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.56 KB | None | 0 0
  1. // AmpDatabase.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include <stdafx.h>
  5. #include <iostream>
  6. #include <string>
  7.  
  8. void MainMenu();
  9.  
  10. bool NotAskedToExit();
  11.  
  12. int choice;
  13.  
  14.  
  15. int main()
  16. {
  17.     bool ToExit = false;
  18.     do
  19.     {
  20.         MainMenu();    
  21.         ToExit = NotAskedToExit();
  22.  
  23.     } while(NotAskedToExit);
  24.  
  25.     return 0; // exit the application
  26. }
  27.  
  28. void MainMenu()
  29. {
  30.         std::cout << "OP-AMP Database menu" << std::endl;
  31.         std::cout << "====================" << std::endl << std::endl;
  32.  
  33.         std::cout << "1. Enter a new op-amp into the database" << std::endl;
  34.         std::cout << "2. Save the database to disk" << std::endl;
  35.         std::cout << "3. Load database from disk" << std::endl;
  36.         std::cout << "4. Sort the database" << std::endl;
  37.         std::cout << "5. Display the database" << std::endl;
  38.         std::cout << "6. Exit from program" << std::endl << std::endl;
  39.  
  40.         std::cout << "Enter choice: ";
  41.         std::cin >> choice;
  42.  
  43.             switch (choice)
  44.             {
  45.                 case 1:
  46.                 std::cout << "case 1";
  47.                 break;
  48.  
  49.                 case 2:
  50.                 std::cout << "case 2";
  51.                 break;
  52.  
  53.                 case 3:
  54.                 std::cout << "case 3";
  55.                 break;
  56.  
  57.                 case 4:
  58.                 std::cout << "case 4";
  59.                 break;
  60.  
  61.                 case 5:
  62.                 std::cout << "case 5";
  63.                 break;
  64.  
  65.                 case 6:
  66.                 NotAskedToExit();
  67.                 break;
  68.  
  69.             default:
  70.             std::cout << "Choose a number between 1 and 6" << std::endl;
  71.             }
  72.  
  73. }
  74.  
  75. bool NotAskedToExit()
  76. {
  77.     std::cout << "Are you sure you want to exit? (y/n) ";
  78.     std::string Response = "";
  79.     std::getline(std::cin, Response);
  80.     return (Response[0] == 'y') || (Response[0] == 'Y');
  81. }
  82.  
  83. /* */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement