CISC 3115 MY9 (SPRING 2023) READINESS EXAM

docx

School

Brooklyn College, CUNY *

*We aren’t endorsed by this school

Course

3115

Subject

Computer Science

Date

Dec 6, 2023

Type

docx

Pages

4

Uploaded by AdmiralWillpowerReindeer28

Report
CISC 3115 MY9 (SPRING 2023) READINESS EXAM NAME: _____________________________________________ PART I: Assuming that the following declarations and initializations have been made, int j=4; int k=5; boolean t1 = true; boolean t2 = false; String text = "freddy-mac"; Int[ ] a = {3, 2, 9, 14, 0, 1}; write a Java literal whose value is equal to the value of each of the following expressions next to the expression in the space provided : (double) (2/j + 4/j + 6/j + 8/j) !(k==5 && j!=k && j==3 ) (t1 && t2) || (!t1 && !t2) text.substring(text.indexOf("red")-1,text.length()-3)+text.charAt(1) a[3]-a[1] * a.length
PART II: (1) Define a method named m1 that receives an array of integers and returns the sum of all those elements in the array whose value exceeds their index and is a multiple of 9. (2) Define a method named m2 that receives an array of doubles returns the index of the largest element in the array. Assume there is at least one element in the array and that there are no duplicates.
(3) Define a method named m3 that receives an array of doubles and another double parameter (let's call it x). The method the number of elements whose value equals x. (4) Write a program P1 that reads an integer (a header) that indicates how many double values follow. The program prints the smallest of the values read. You may assume that there is at least one value.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
(5) Write a program P2 that reads integers from standard input; when it encounters the value 0, it prints the number of negative values read since the previous 0. Assume that the first and last values in the standard iinput are 0. The program terminates when there is no more data. Example: if the input is "0 3 8 -4 2 7 -1 0 4 0 -2 -3 -7 0" then the output will be "2 0 3". (Note: output format doesn't matter.)