Advertisement
Guest User

Untitled

a guest
Jul 28th, 2015
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.23 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5.     bool isAccepted = false;
  6.     bool isCapital = false;
  7.     char charInput1 = (char)65;
  8.     char charInput2 = (char)65;
  9.  
  10.     std::cout << "This program gets the middle letter of of 2 letters that have been input" << std::endl;
  11.     while(isAccepted == false){
  12.         std::cout << "Enter the first letter: ";
  13.         std::cin >> charInput1;
  14.         std::cout << "Enter the second letter: ";
  15.         std::cin >> charInput2;
  16.        
  17.         if(charInput1 >= 65 && charInput2 >= 65 && charInput1 <= 90 && charInput2 <= 90)
  18.         {
  19.             char charAnswer = (charInput1 + charInput2) / 2;
  20.             std::cout << "You have selected: " << charInput1 << " and " << charInput2 << ". The middle letter is: " << charAnswer << std::endl;
  21.             isCapital = true;
  22.             isAccepted = true;
  23.         }
  24.         else if(charInput1 <= 122 && charInput2 <= 122 && charInput1 >= 97 && charInput2 >= 97)
  25.         {  
  26.             char charAnswer = (charInput1 + charInput2) / 2;
  27.             std::cout << "You have selected: " << charInput1 << " and " << charInput2 << ". The middle letter is: " << charAnswer << std::endl;
  28.             isAccepted = true;
  29.         }
  30.         else{
  31.             std::cout << "You've had an invalid selection. Make sure you don't use a caption and a lowercase or any symbols" << std::endl;
  32.         }
  33.     }
  34.     system("pause");
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement