This program determines whether or not a person is eligible for insurance based on their marital status, gender, and age. The program first asks the user to enter their marital status as either "M" for married or "U" for unmarried. The input is read in using the "cin" statement and stored in the variable "marital".
If the marital status is "M" or "m", the program outputs "You are Eligible For Insurance" because married people are automatically eligible for insurance. If the marital status is "U" or "u", the program prompts the user to enter their gender as "M" for male or "F" for female, and their age. The inputs are read in using the "cin" statement and stored in the variables "gender" and "age", respectively.
The program then checks if the gender is male and the age is 30 or older, or if the gender is female and the age is 25 or older. If either of these conditions are true, the program outputs "You are Eligible For Insurance". If not, the program outputs "You are Not Eligible For Insurance" and an additional message indicating that the input for gender is invalid.
If the user enters an invalid input for marital status, the program outputs "Invalid Marital Input". At the end of the program, it returns 0 to indicate successful execution.
/* A company insures its drivers in the following cases: a. If the driver is married. b. If the driver is unmarried, male & above 30 years of age. c. If the driver is unmarried, female & above 25 years of age. */ #include<iostream> using namespace std; int main() { char marital,gender; int age; cout<<"\nEnter Marital Status : M as Married | U as Unmarried : "; cin>>marital; if(marital=='M' || marital=='m') { cout<<"\nYou are Eligible For Insurance"; } else if(marital=='U' || marital=='u') { cout<<"\nEnter Gender : M as Male | F as Female : "; cin>>gender; cout<<"\nEnter Age : "; cin>>age; if(((gender=='M' || gender=='m')&&age>=30) || ((gender=='F' || gender=='f')&&age>=25)) { cout<<"\nYou are Eligible For Insurance"; } else { cout<<"\nYou are Not Eligible For Insurance..."; cout<<"\nor"; cout<<"\nInvalid Gender Input...."; } } else { cout<<"\nInvalid Marital Input...."; } return 0; } /* ((gender=='M' || gender=='m')&&age>=30) || ((gender=='F' || gender=='f')&&age>=25) */
Enter Marital Status : M as Married | U as Unmarried : U Enter Gender : M as Male | F as Female : F Enter Age : 27 You are Eligible For InsuranceTo download raw file Click Here
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions