File Name: ArrayOperations.java Class Name: ArrayOperations Problem Description: Write a program to perform the following operations on an array: 1. Initialize integer arrays with input values 2. Print array 3. Search a number and return its index if it is present otherwise return -1 4. Find the smallest odd number from the array 5. Exit Note: To find the smallest number, it is required initialize the smallest number variable to the larger number which is not present in the array. You can initialize the smallest number to Integer.MAX_VALUE; Guidelines: 1. Use switch case and while loop. 2. Variables to declare in main method- An array of integer datatype 3. Use methods to write each operation listed in problem description and pass array as an argument to all methods. Steps to follow: 1. Declare anarray of size 5 2. Display array operations 3. Input user choice 4. Use the switch case to call the appropriate method 4. Implement the methods in your program for all operations listed in the problem description 5. Loop again to display array operations. Provide and exit the loop (hint: use return statement) Operations 1. Initialize Array 2. Print Array 3. Search a number 4. Find smallest odd number 5. Exit Enter your choice: 1 Enter the array values: 11 12 13 14 15 Operations 1. Initialize Array 2. Print Array 3. Search a number 4. Find the smallest odd number 5. Exit Enter your choice: 2 Array - 11 12 13 14 15 Operations 1. Initialize Array 2. Print Array 3. Search a number 4. Find the smallest odd number 5. Exit Enter your choice: 3

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 9PE
icon
Related questions
Question
File Name: ArrayOperations.java
Class Name: ArrayOperations
Problem Description:
Write a program to perform the following operations on an array:
1. Initialize integer arrays with input values
2. Print array
3. Search a number and return its index if it is present otherwise return -1
4. Find the smallest odd number from the array
5. Exit
Note: To find the smallest number, it is required initialize the smallest number variable to
the larger number which is not present in the array. You can initialize the smallest number to
Integer.MAX_VALUE;
Guidelines:
1. Use switch case and while loop.
2. Variables to declare in main method- An array of integer datatype
3. Use methods to write each operation listed in problem description and pass array as an
argument to all methods.
Steps to follow:
1. Declare anarray of size 5
2. Display array operations
3. Input user choice
4. Use the switch case to call the appropriate method
4. Implement the methods in your program for all operations listed in the problem
description
5. Loop again to display array operations. Provide and exit the loop (hint: use return
statement)
Transcribed Image Text:File Name: ArrayOperations.java Class Name: ArrayOperations Problem Description: Write a program to perform the following operations on an array: 1. Initialize integer arrays with input values 2. Print array 3. Search a number and return its index if it is present otherwise return -1 4. Find the smallest odd number from the array 5. Exit Note: To find the smallest number, it is required initialize the smallest number variable to the larger number which is not present in the array. You can initialize the smallest number to Integer.MAX_VALUE; Guidelines: 1. Use switch case and while loop. 2. Variables to declare in main method- An array of integer datatype 3. Use methods to write each operation listed in problem description and pass array as an argument to all methods. Steps to follow: 1. Declare anarray of size 5 2. Display array operations 3. Input user choice 4. Use the switch case to call the appropriate method 4. Implement the methods in your program for all operations listed in the problem description 5. Loop again to display array operations. Provide and exit the loop (hint: use return statement)
Operations
1. Initialize Array
2. Print Array
3. Search a number
4. Find smallest odd number
5. Exit
Enter your choice: 1
Enter the array values:
11
12
13
14
15
Operations
1. Initialize Array
2. Print Array
3. Search a number
4. Find the smallest odd number
5. Exit
Enter your choice: 2
Array - 11
12
13
14
15
Operations
1. Initialize Array
2. Print Array
3. Search a number
4. Find the smallest odd number
5. Exit
Enter your choice:
3
Transcribed Image Text:Operations 1. Initialize Array 2. Print Array 3. Search a number 4. Find smallest odd number 5. Exit Enter your choice: 1 Enter the array values: 11 12 13 14 15 Operations 1. Initialize Array 2. Print Array 3. Search a number 4. Find the smallest odd number 5. Exit Enter your choice: 2 Array - 11 12 13 14 15 Operations 1. Initialize Array 2. Print Array 3. Search a number 4. Find the smallest odd number 5. Exit Enter your choice: 3
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 6 steps

Blurred answer
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
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage