Write a java program that prompts the user to enter ten integer values and reads them into an array. The program should consist of the following methods: • a method named countOccurences that accepts an array of integer values and an integer search value. This method should return the number of occurrences of the integer search value. • a method named searchIndex that accepts an array of integer values and an integer search value. This method should return the index of the last occurrence of the search value. If the search value does not occur in the array the method should return -1. • a method named sumWithoutSmallest that accepts an array of integer values and returns the sum of all the values in the array except the smallest one

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 1TF: Mark the following statements as true or false. A double type is an example of a simple data type....
icon
Related questions
Question

1) Write a java program that prompts the user to enter ten integer values and reads them into an array.
The program should consist of the following methods:
• a method named countOccurences that accepts an array of integer values and an
integer search value. This method should return the number of occurrences of the
integer search value.
• a method named searchIndex that accepts an array of integer values and an integer
search value. This method should return the index of the last occurrence of the search
value. If the search value does not occur in the array the method should return -1.
• a method named sumWithoutSmallest that accepts an array of integer values and
returns the sum of all the values in the array except the smallest one.
Invoke the above methods and demonstrate them in the program. Save the program as
ArrayOperations.java.
Here is a sample run:
Enter ten numbers: 2 3 4 4 2 7 4 5 6 3
Enter a search value: 4
The number 4 occurs 3 times in the array
The last occurrence of number 4 is at index position 6
The sum of all the values in the array except the smallest is:
36

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 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
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