Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

in java 1) Assume that x is a char variable has been declared and already given

ID: 3804763 • Letter: I

Question

in java

1) Assume that x is a char variable has been declared and already given a value . Write an expression whose value is true if and only if x is NOT a upper-case letter.

2)

You are given two int variables j and k, an int array zipcodeList that has been declared and initialized , and an boolean variable duplicates.

Write some code that assigns true to duplicates if any two elements in the array have the same value , and that assigns false to duplicates otherwise. Use only j, k, zipcodeList, and duplicates.

3)

Given :

an int variable k,

an int array currentMembers that has been declared and initialized ,

an int variable memberID that has been initialized , and

an boolean variable isAMember,

write code that assigns true to isAMember if the value of memberID can be found in currentMembers, and that assigns false to isAMember otherwise. Use only k, currentMembers, memberID, and isAMember.

4)

You are given an int variable k, an int array zipcodeList that has been declared and initialized , and an boolean variable duplicates.

Write some code that assigns true to duplicates if there are two adjacent elements in the array that have the same value , and that assigns false to duplicates otherwise. Use only k, zipcodeList, and duplicates.

Explanation / Answer

Please find my answer.

//1.

       char char_variable = 'C';

       boolean exp_value = Character.isUpperCase(char_variable) ? true : false;

      

       //2.

       boolean duplicates;

       int[] zipcodeList = new int[10]; // array declaration

       int j=3, k = 4; // initialized with some value

       duplicates = zipcodeList[j] == zipcodeList[k] ? true : false;

      

       //3

       int k;

       int[] currentMembers = {1,2,3,4,5,6,7,8,9,10};

       int memberID;

       boolean isAMember = false;

      

       for(k=0; k<currentMembers.length; k++)

           if(currentMembers[k] == memberID)

               isAMember = true;

//4

       boolean duplicates = false;

       int[] zipcodeList = new int[10]; // array declaration

       int k; // initialized with some value

      

       for(k=0; k<zipcodeList.length-1; k++)

           if(zipcodeList[k] == zipcodeList[k+1])

               duplicates = true;