A good Employee is defined who has all the following properties:
1. Employee must be married.
2. Employee has at least 2 children
3. His Middle Name Start with “K” and Ends With “E”.
4. His Last Name has at least 4 characters, and starts with “A”
5. In His childrens have at least one name “Raja”.
Write a method:
boolean isGoodEmployee( boolean isMarried, int noOfChild , String middleName , String lastName , String[] childNames){
Answer:
import java.io.*;
class Employ
{
boolean isMarried;
int noOfChild;
String middleName;
String lastName;
String[] childNames;
boolean isGoodEmployee( boolean isMarried, int noOfChild , String middleName , String lastName , String[] childNames){
this.isMarried=isMarried;
this.noOfChild=noOfChild;
this.middleName=middleName;
this.lastName=lastName;
this.childNames=childNames;
int mlength=middleName.length();
int ml=mlength-1;
int lnLength=lastName.length();
int count=0,name=0;
int childln=childNames.length;
if(isMarried==true)
{
//return true;
}else {
System.out.println("He is not Married");
}
if (noOfChild<=2){
//return true;
}else {
System.out.println("not about children");
}
//System.out.println(ml);
// System.out.println(middleName.c harAt(ml));
// System.out.println(middleName.c harAt(0));
if(middleName.charAt(0)=='k') {
if(middleName.charAt(ml)!='e') {
// return true;
}else{
System.out.println("Name not in COrrect formate");
}
}
if(lnLength>4){
for(int i=0;iif(lastName.charAt(i)=='a')
count=count+1;
}
//System.out.println(count);
if(count>=2){
}else{
System.out.println("Last Name not in Correct form");
}
}
// System.out.println(childNames[0 ]);
//System.out.println(childln);
for(int i=0;i{
if(childNames[i].equals("Raja" )){
name=name+1;
}
if(name>=1){
//return true;
}else{
System.out.println("NO One Children is RAJA");
}
}
System.out.println(" Good Employee");
return true;
}
public static void main(String[] args)
{
String mName="kiranew";
String lName="Maadhu";
boolean married=true;
String[] childN={"Raja","Latha"};
int noChild=2;
Employ em=new Employ();
em.isGoodEmployee(married,noCh ild,mName,lName,childN);
}
}
1. Employee must be married.
2. Employee has at least 2 children
3. His Middle Name Start with “K” and Ends With “E”.
4. His Last Name has at least 4 characters, and starts with “A”
5. In His childrens have at least one name “Raja”.
Write a method:
boolean isGoodEmployee( boolean isMarried, int noOfChild , String middleName , String lastName , String[] childNames){
Answer:
import java.io.*;
class Employ
{
boolean isMarried;
int noOfChild;
String middleName;
String lastName;
String[] childNames;
boolean isGoodEmployee( boolean isMarried, int noOfChild , String middleName , String lastName , String[] childNames){
this.isMarried=isMarried;
this.noOfChild=noOfChild;
this.middleName=middleName;
this.lastName=lastName;
this.childNames=childNames;
int mlength=middleName.length();
int ml=mlength-1;
int lnLength=lastName.length();
int count=0,name=0;
int childln=childNames.length;
if(isMarried==true)
{
//return true;
}else {
System.out.println("He is not Married");
}
if (noOfChild<=2){
//return true;
}else {
System.out.println("not about children");
}
//System.out.println(ml);
//
//
if(middleName.charAt(0)=='k') {
if(middleName.charAt(ml)!='e')
// return true;
}else{
System.out.println("Name not in COrrect formate");
}
}
if(lnLength>4){
for(int i=0;i
count=count+1;
}
//System.out.println(count);
if(count>=2){
}else{
System.out.println("Last Name not in Correct form");
}
}
//
//System.out.println(childln);
for(int i=0;i
if(childNames[i].equals("Raja"
name=name+1;
}
if(name>=1){
//return true;
}else{
System.out.println("NO One Children is RAJA");
}
}
System.out.println(" Good Employee");
return true;
}
public static void main(String[] args)
{
String mName="kiranew";
String lName="Maadhu";
boolean married=true;
String[] childN={"Raja","Latha"};
int noChild=2;
Employ em=new Employ();
em.isGoodEmployee(married,noCh
}
}
No comments:
Post a Comment