Answer on Question #48225 – Engineering – Other
The function will return true if and only if a passport holder satisfies following conditions-
A passport holder should not be a criminal.
A passport holder must have only one nationality and it should be "Indian".
A passport holder must be living at current address for more than 12 months.
A valid passport holder must hold at least two degrees from the list: "High School", "Intermediate", "Graduate", "Professional"
Write a method:
boolean isValidIndianPassportHolder(boolean isCriminal, String[] qualifications);
isCriminal Value of this variable will be true, if passport holder is criminal otherwise false
nationalities A string array of nationalities which cannot be null
livingMonths This variable defines the number of months the passport holder was living at the given address
qualifications This variable defines a string array which defines qualifications (e.g. High School, Intermediate,
Graduate of the passport ho
Solution (C#)
bool isValidIndianPassportHolder(bool isCriminal, String[] nationalities, float livingMonths, String[] qualifications)
{
int count = 0;
for (int i = 0; i < qualifications.Length; i++)
if (qualifications[i].Equals("High School")) || qualifications[i].Equals("Intermediate")) ||
qualifications[i].Equals("Graduate")) ||
qualifications[i].Equals("Professional"))
count++;
bool j = false;
for (int i = 0; i < nationalities.Length; i++)
if (nationalities[i].Equals("Indian")) j = true;
if ((isCriminal == true) && j && (livingMonths > 12) && (count > 1))
return true;
else
return false;
}http://www.AssignmentExpert.com/
Comments