Badboy is defined who has ALL the following properties:
1. Does not have a girlfriend and is not married.
2. He is not more than 23 years old.
3. The middle name should be "Singh"
4. The last name should have more than 4 characters.
5. The character 'a' should appear in the last name at
least two times.
6. The name of one of his brothers should be "Ram"
Write a method:
boolean isBadBoy(boolean hasGirlFriend , boolean isMarried,
int age , String middleName , String lastName , String[]
brotherName);
isHaveGirlFriend is true if the person has a girlfriend
isMarried is true if the person is married
age is the age of the person
middleName is the middle name of the person
lastName is the last name of the person
brotherName is the array of the names of his brothers
Answer / pramod kumar srivastava
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
char gf[25],f_name[10],m_name[10],l_name[25],brother_name[20];
int age;
char a[10],b[10];
cout<<"enter the f_name";
cin>>f_name;
cout<<"enter your middle name";
cin>>m_name;
cout<<"enter your last name";
cin>>l_name;
cout<<"enter your age";
cin>>age;
cout<<"are you have girlfriend yes / no";
cin>>a;
if(a=="yes")
{
cout<<"enter gf name";
cin>>gf;
cout<<" is have gf";
}
if(a=="no")
{
cout<<"no gf";
}
cout<<"r u married";
cin>>b;
if(b=="yes")
{
cout<<"he is married";
}
if(b=="no")
{
cout<<"single";
}
cout<<"enter your brother name\n";
cin>>brother_name;
cout<<"age is: "<<age;
cout<<"\nmiddlename is"<<m_name;
cout<<"\nlast name is: "<<l_name;
cout<<"\nbrother name is: "<<brother_name;
if((age<=23)&&(m_name=="singh")&&(brother_name=="ram")&&(a=="no")&&(b=="no"))
{
cout<<"he is bad boy";
}
getch();
}
Is This Answer Correct ? | 2 Yes | 0 No |
please help to write the code of chess game in c++??????????
Where and why do I have to put the "template" and "typename" keywords?
Explain the scope of resolution operator.
Can you overload the operator+ for short integers?
What is the difference between method overloading and method overriding in c++?
Difference between an inspector and a mutator
How can virtual functions in c++ be implemented?
Why do we need pointers?
What is ios class in c++?
what is Loop function? What are different types of Loops?
Is c++ still in demand?
What is a 'pure' virtual function and what's its use?