1) Write a static method named computeOddSum that is passed an array of int's named numbers. The method must compute and return the sum of all the values in numbers that are odd. For example, if numbers is {3, 10, 11, 2, 6, 9, 5} then the value 28 should be returned since 3 + 11 + 9 + 5 = 28 is the sum of all the odd values in numbers. 2) Write a static method named replaceEvens that receives the parameter numbers which is an array of int's. The method must replace all elements of numbers that store even values with the negative of that value. That is, if the number 12 is found in a given position of numbers, then the method must replace the 12 with a -12. You can assume that all values in the array are positive numbers greater than zero. 3) Write a static, void method named replaceAll that accepts an array of int's named numbers as well as an int named num. The method must replace all occurrences of num that are found in even-numbered index positions with the value of 3. That is, if the value num is stored in numbers[4] then it must be replaced with the value 3 since 4 is an even number. But if num is found in numbers[5] , it must not be replaced since 5 is not an even number. For this exercise, zero is considered to be an even number. The method must work for an array of any size. 4) There is a non-empty array of String's named names. Write a code segment that removes the last letter of the String stored in the very last position of names. For bragging rights and if possible (and I'm not sure if it is), write a single statement that performs this task.
1) Write a static method named computeOddSum that is passed an array of int's named numbers. The method must compute and return the sum of all the values in numbers that are odd. For example, if numbers is {3, 10, 11, 2, 6, 9, 5} then the value 28 should be returned since 3 + 11 + 9 + 5 = 28 is the sum of all the odd values in numbers. 2) Write a static method named replaceEvens that receives the parameter numbers which is an array of int's. The method must replace all elements of numbers that store even values with the negative of that value. That is, if the number 12 is found in a given position of numbers, then the method must replace the 12 with a -12. You can assume that all values in the array are positive numbers greater than zero. 3) Write a static, void method named replaceAll that accepts an array of int's named numbers as well as an int named num. The method must replace all occurrences of num that are found in even-numbered index positions with the value of 3. That is, if the value num is stored in numbers[4] then it must be replaced with the value 3 since 4 is an even number. But if num is found in numbers[5] , it must not be replaced since 5 is not an even number. For this exercise, zero is considered to be an even number. The method must work for an array of any size. 4) There is a non-empty array of String's named names. Write a code segment that removes the last letter of the String stored in the very last position of names. For bragging rights and if possible (and I'm not sure if it is), write a single statement that performs this task.
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Write a Java computer
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 8 steps with 11 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY