Instructions:
For each of the questions below, design a class with the following basic structure:
Data members:
arr : array to store elements
n : size of the array
Member functions:
Parameterised constructor to allocate memory to array (optional)
void input() : To input values into the array
void compute() : To perform the required task for each question. (You may change the name and make it relevant to the task of the question)
void display() : To display as per the requirement of each question
Write a main() method to create an object of the class and call all other methods in appropriate order.
Questions:
Write a program in java to reverse the array. (The same array should be reversed). Display the array original array as well as reversed array
For example: arr = {1,2,3,4,5,6}
After reversal arr = {6,5,4,3,2,1}
Write a Program in Java to find the duplicate values in an array. Display the original array and all the duplicate values along with its frequency of duplication.
For example: arr = {1,2,3,2,4,5,4,2,1,2}
It should display:
Duplicate elements:
1 - 2 times
2 - 4 times
4 - 2 times
Write a Java program to find all pairs of elements in an array whose sum is equal to a specified number (to be taken as user input).
For example: arr = {2,5,3,8,4,10,-3,-1}
Sum to be checked = 7
It should display:
Pairs whose sum is 7 are:
2 and 5
3 and 4
-3 and 10
8 and -1
4. Write a Java program to find maximum product of two integers in an array of integers.
For example: arr = {2,5,3,8,4,10}
It should display:
Maximum product of two integers in the array is = 80
Answers
Answered by
0
Answer:
days ago and me to be in my life is the answer my questions and me to be a good day is the answer is no longer be a great time with help from the bottom and the other side and the best way to be a good day is no way home and the best way to be a good time happy birthday party at my house and answer is no way home from school and answer is no longer have a good day for me to get a chance to win
Similar questions