Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <clocale>
- using namespace std;
- int main() {
- char Gen;
- int Age, ReAge;
- bool isNotCorrect = false;
- cout << "This program will find the recommended age for marriage" << '\n' << "Man or Woman ? ENTER M if you are a man or W if you are a woman and your age." << '\n';
- do
- {
- cin >> Gen >> Age;
- if (cin.fail()) {
- isNotCorrect = true;
- cout << "Data entered incorrectly, please re-enter" << '\n';
- cin.clear();
- while (cin.get() != '\n');
- }
- else {
- isNotCorrect = false;
- if (Gen != 'M' && Gen != 'W') {
- cout << "Enter existing gender" << '\n';
- isNotCorrect = true;
- }
- if (Age < 16 || Age > 100) {
- cout << "Re-enter with acceptable age(16-100)" << '\n';
- isNotCorrect = true;
- }
- }
- } while (isNotCorrect);
- if (Gen == 'M')
- ReAge = Age / 2 + 7;
- else
- ReAge = Age * 2 - 14;
- cout << "Recommended age of a candidate for marriage : " << ReAge;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement