Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <thread>
  4. #include <chrono>
  5.  
  6. int main(int, const char *) {
  7. while (true) {
  8. std::cout << "[0]: Hex to Decimal" << std::endl;
  9. std::cout << "[1]: Decimal to Hex" << std::endl;
  10. std::cout << "[2]: Quit" << std::endl;
  11. std::cout << "Enter the index and hit enter" << std::endl;
  12. int indexChosen = NULL;
  13. std::cin >> indexChosen;
  14. if (!indexChosen) {
  15. std::cout << "Selected Hex to Decimal" << std::endl;
  16. int in;
  17. std::cin >> std::hex >> in;
  18. std::cout << "Hex to Decimal: " << in << std::endl << std::endl;
  19. } else if (indexChosen == 1) {
  20. std::cout << "Selected Decimal to Hex" << std::endl;
  21. int in;
  22. std::cin >> in;
  23. std::cout << "Decimal to Hex: " << std::hex << in << std::endl << std::endl;
  24. } else if (indexChosen == 2) {
  25. break;
  26. } else {
  27. std::cout << "Invalid choice" << std::endl;
  28. }
  29. std::this_thread::sleep_for(std::chrono::milliseconds(100));
  30. }
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement