Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main()
- {
- bool isAccepted = false;
- bool isCapital = false;
- char charInput1 = (char)65;
- char charInput2 = (char)65;
- std::cout << "This program gets the middle letter of of 2 letters that have been input" << std::endl;
- while(isAccepted == false){
- std::cout << "Enter the first letter: ";
- std::cin >> charInput1;
- std::cout << "Enter the second letter: ";
- std::cin >> charInput2;
- if(charInput1 >= 65 && charInput2 >= 65 && charInput1 <= 90 && charInput2 <= 90)
- {
- char charAnswer = (charInput1 + charInput2) / 2;
- std::cout << "You have selected: " << charInput1 << " and " << charInput2 << ". The middle letter is: " << charAnswer << std::endl;
- isCapital = true;
- isAccepted = true;
- }
- else if(charInput1 <= 122 && charInput2 <= 122 && charInput1 >= 97 && charInput2 >= 97)
- {
- char charAnswer = (charInput1 + charInput2) / 2;
- std::cout << "You have selected: " << charInput1 << " and " << charInput2 << ". The middle letter is: " << charAnswer << std::endl;
- isAccepted = true;
- }
- else{
- std::cout << "You've had an invalid selection. Make sure you don't use a caption and a lowercase or any symbols" << std::endl;
- }
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement