Problem 1 - Methods Write a program that has a loop of three iterations. In every iteration, the program should prompt the user to enter three integers then invoke a method called hasOddEven that takes the three integers as parameters and returns true if there is at least one odd and at least one even among the three numbers and that returns false otherwise. Below are some sample calls and the returned value: Method Call Value Returned |hasOddEven(2, 4, 6) False hasOddEven(2, 3, 4) True hasOddEven(12, 4, 17) True hasOddEven(7, 19, 5) False

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter9: Advanced Modularization Techniques
Section: Chapter Questions
Problem 13RQ
icon
Related questions
Question
100%
Problem 1 - Methods
Write a program that has a loop of three iterations. In every iteration, the program should prompt the user to
enter three integers then invoke a method called hasOddEven that takes the three integers as parameters and
returns true if there is at least one odd and at least one even among the three numbers and that returns false
otherwise. Below are some sample calls and the returned value:
Method Call
Value Returned
hasOddEven(2, 4, 6)
False
hasOddEven(2, 3, 4)
True
hasOddEven(12, 4, 17)
True
hasOddEven(7, 19, 5)
False
Problem 2 - Arrays
Write a method that takes an array of integers and print the elements of the array. The header of the method is:
public static void displayArray (int [] arr)
Write a main method in which you create an array named a of size entered by the user (the size should be even).
Then fill the array a with values read from the user. Split the array a into two arrays b and c as follows:
a
4
65
23
94
12
56
33
89
34
23
b
4
65
23
94
12
56
33
89
34
23
Finally, call the method dislayArray to print arrays b and c.
Transcribed Image Text:Problem 1 - Methods Write a program that has a loop of three iterations. In every iteration, the program should prompt the user to enter three integers then invoke a method called hasOddEven that takes the three integers as parameters and returns true if there is at least one odd and at least one even among the three numbers and that returns false otherwise. Below are some sample calls and the returned value: Method Call Value Returned hasOddEven(2, 4, 6) False hasOddEven(2, 3, 4) True hasOddEven(12, 4, 17) True hasOddEven(7, 19, 5) False Problem 2 - Arrays Write a method that takes an array of integers and print the elements of the array. The header of the method is: public static void displayArray (int [] arr) Write a main method in which you create an array named a of size entered by the user (the size should be even). Then fill the array a with values read from the user. Split the array a into two arrays b and c as follows: a 4 65 23 94 12 56 33 89 34 23 b 4 65 23 94 12 56 33 89 34 23 Finally, call the method dislayArray to print arrays b and c.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
List
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
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT