1. Engineering
  2. Computer Science
  3. 2 question 2 part a given the following method int...

Question: 2 question 2 part a given the following method int...

Question details

2 Question 2 Part A Given the following method int pmethodA(intx, int y) if(x<y) return -1 else if (x== y) return 0; else return 1; What would be returned for the following calls: i methodA(3, 3) imetbodA (5, 4) iimethodA (20, 30) iv. In general, what does the method return v. Are there any other cases to take into consideration that are not covered by the above three calls? Answer either No, or provide such a case vi.Rewrite the method eliminating the if statements, instead use
vi. Rewrite the method eliminating the if statements, instead use VI. conditional operators only Part B Given the following method: String restof(String s) ( return s.substring(1), What is returned by each of the following expressions: i + restOfHello) i restOf(restof(restof cowboy) 994
2017FalICISC1115Samplefinal (1).doc (Protected View) -Word (Unlicensed Product) ngs Review View Help Tell me what you want to do ruses. Unless you need to edit, its safer to stay in Protected View. Enable Editing d because it hasnt been activated. Activate Question 5 Write a complete Java program to do the following: Read from a file input5.txt a list of pairs of integers. For each pair, if the sum of the two numbers is positive, calculate as a decimal number the first divided by the second. If the sum is negative, calculate as a decimal number the second divided by the first. You may assume neither value is zero. a. b. Write the two numbers and the calculated quotient to a file output5.txt, one pair per line. Do this until there is no more data to read.
2017FalICISC1115Samplefinal (1).docx (Protected View)-Word (Unlicensed Product) Review View HelpTell me what you want to do es Unless you need to edit, its safer to stay in Protected View. Enable Editing ecause it hasnt been activated. Activate At the end, print 2 things with an appropriate message: The number of pairs processed, and the value of the quotient closest to zero. Remember that the quotient may be positive or negative. c.
Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution