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 Posted / 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 |
Post New Answer View All Answers
What's the order in which the objects in an array are destructed?
What do you mean by volatile and mutable keywords used in c++?
What is difference between rand () and srand ()?
Write a program to find the reverse Fibonacci series starting from N.
What are the advantage of using register variables?
What are activex and ole?
What is difference between class and structure in c++?
Can I make ios apps with c++?
Can member functions be private?
List down the guideline that should be followed while using friend function.
Explain the difference between c++ and java.
How do I write a c++ program?
What is the arrow operator in c++?
Differentiate between an external iterator and an internal iterator?
What is doubly linked list in c++?