You are given an array of integers below. Write a Java program to perform the following operation on the array. Double the number if both the adjacent elements are equal. • Subtract the number from 5 if both the adjacent elements are not equal but both are odd. The array should be modified in one go, i.e. once an element is modified, the original number should be considered for the modification of the remaining numbers and not the modified number. int [Jarr = {12, 7, 12, 53, 2, 5, 49, 5, 21, 0}

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 11RQ
icon
Related questions
Question
100%
You are given an array of integers below. Write a Java program to perform the following operation on the array.
• Double the number if both the adjacent elements are equal.
Subtract the number from 5 if both the adjacent elements are not equal but both are odd.
The array should be modified in one go, i.e. once an element is modified, the original number should be considered
for the modification of the remaining numbers and not the modified number.
int [Jarr = {12, 7, 12, 53, 2, 5, 49, 5, 21, 0}
Transcribed Image Text:You are given an array of integers below. Write a Java program to perform the following operation on the array. • Double the number if both the adjacent elements are equal. Subtract the number from 5 if both the adjacent elements are not equal but both are odd. The array should be modified in one go, i.e. once an element is modified, the original number should be considered for the modification of the remaining numbers and not the modified number. int [Jarr = {12, 7, 12, 53, 2, 5, 49, 5, 21, 0}
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT