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
Describe protected access specifiers?
When we use Abstract Class and when we use Interface?where we will implement in real time?
How does com provide language transparency?
What parameter does the constructor to an ofstream object take?
How can I learn dev c++ programming?
What is std :: flush?
write asingle linked list which read from two list & the do the following 1 sort the prime & nonprime num (prime should be less tn nonprime) 2 each node has a prime num followd by nonprime 3 add a new node into its sutable plce 4 erase the most three duplicated non prime num 5 find the least duplicated prime num
Is there finally in c++?
What is the main purpose of overloading operators?
When does a name clash occur in c++?
Is swift faster than c++?
What happens when the extern "c" char func (char*,waste) executes?
Does there exist any other function which can be used to convert an integer or a float to a string?
Does std endl flush?
State the difference between delete and delete[].