Advertisement
Guest User

Untitled

a guest
May 4th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main() {
  6.  
  7. string test;
  8. string test2;
  9. string varSelect; //used to control which text will be repeated
  10. bool varSuccess = false; //controls if the variable was correctly input, initially false to start loop
  11. bool loop = true; //controls if we want to keep looping the request to print either string
  12. cout << "Please enter a some text: " << endl;
  13. getline(cin, test);
  14. cin.clear();
  15. cout << "Please enter another text: " << endl;
  16. getline(cin, test2);
  17. cin.clear();
  18. while (loop = true) {
  19. while (varSuccess = false) {
  20. cout << "If you would like the first text, type a, if you would like the second, type b" << endl;
  21. getline(cin, varSelect);
  22. cin.clear();
  23. cout << varSelect[0] << endl;
  24. if ((varSelect.length() == 1) && (varSelect[0]> 96) && (varSelect[0] < 100)) {
  25. varSuccess = true;
  26. }
  27. }
  28. if (varSelect[0] == 97) {
  29. cout << test << endl;
  30. }
  31. if (varSelect[0] == 98) {
  32. cout << test2 << endl;
  33. }
  34. if (varSelect[0] == 99) {
  35. loop = false;
  36. }
  37. }
  38. cout << "See you next time" << endl;
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement