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

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 19PE
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
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,