Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // AmpDatabase.cpp : Defines the entry point for the console application.
- //
- #include <stdafx.h>
- #include <iostream>
- #include <string>
- void MainMenu();
- bool NotAskedToExit();
- int choice;
- int main()
- {
- bool ToExit = false;
- do
- {
- MainMenu();
- ToExit = NotAskedToExit();
- } while(NotAskedToExit);
- return 0; // exit the application
- }
- void MainMenu()
- {
- std::cout << "OP-AMP Database menu" << std::endl;
- std::cout << "====================" << std::endl << std::endl;
- std::cout << "1. Enter a new op-amp into the database" << std::endl;
- std::cout << "2. Save the database to disk" << std::endl;
- std::cout << "3. Load database from disk" << std::endl;
- std::cout << "4. Sort the database" << std::endl;
- std::cout << "5. Display the database" << std::endl;
- std::cout << "6. Exit from program" << std::endl << std::endl;
- std::cout << "Enter choice: ";
- std::cin >> choice;
- switch (choice)
- {
- case 1:
- std::cout << "case 1";
- break;
- case 2:
- std::cout << "case 2";
- break;
- case 3:
- std::cout << "case 3";
- break;
- case 4:
- std::cout << "case 4";
- break;
- case 5:
- std::cout << "case 5";
- break;
- case 6:
- NotAskedToExit();
- break;
- default:
- std::cout << "Choose a number between 1 and 6" << std::endl;
- }
- }
- bool NotAskedToExit()
- {
- std::cout << "Are you sure you want to exit? (y/n) ";
- std::string Response = "";
- std::getline(std::cin, Response);
- return (Response[0] == 'y') || (Response[0] == 'Y');
- }
- /* */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement