Advertisement
Guest User

same

a guest
Oct 21st, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <climits>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. char yn;
  11. do
  12. {
  13.  
  14. yn = ' ';
  15.  
  16. short b;
  17. cout << "enter short b" << endl;
  18. cin >> b;
  19. short a;
  20. cout << "\nenter short a" << endl;
  21. cin >> a;
  22.  
  23. cout << "\n\n " << a+b << " is the answer" << endl;
  24.  
  25. cout << "\nWould you like to translate another number?(y/n)" << endl;
  26. cin >> yn;
  27.  
  28. while (isdigit(yn))
  29. {
  30. cout << "\nYou've entered a number, please enter the character 'y' or the character 'n' on your keyboard!" << endl;
  31. cin >> yn;
  32.  
  33. }
  34.  
  35. yn = tolower(yn);
  36.  
  37. cin.clear();
  38. cin.ignore(INT_MAX,'\n');
  39.  
  40. } while (yn == 'y');
  41.  
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement