quiz حل الأسئلة الجامعية manage_search الأرشيف

تم الحل ✓
categoryبرمجة وتطوير البرمجيات schoolبكالوريوس event_available2026-07-15

السؤال

Transcribed Image Text:

Problem Description: Write a Java program that has two classes: TestOddNumbers and OddNumbers. The former class contains ONLY the main method. In this method, you are asked to write the necessary code for creating a one-dimensional integer array, intArray, and initializing its entries with the following elements: {2, 3, 5, 4, 10, 15, 12, 7, 9}. In the latter class, you are asked to write following static methods that manipulate this array: 1. Method name: countOddNumbers Parameters: int[] a Return: int hou base Logic: counts the odd i values 2. Method name: Parameters: int[] a Return: int in the array a and retums the number of odd OddNumbers. Logic: computes the sum of the odd numbers in the array a and retums the summation. 3. Method name: averageOddNumber. Parameters: int a[] Return: double Logic: computes the average of the odd numbers in the array a and returns the average. Hint: call the method sumOddNumbers to compute the sum of the odd numbers in the array a and then divide the returned value by the length of the array a. ©2011 Dr. Abdulbaset Gaddah, <Computer Programming > [1] Lab 12: 4. Method name: largestOddNumber. Parameters: int a[] Return: String Arrays Logic: finds and retums the largest odd number in the array a. If odd numbers cannot be found, this method should return the following text "Odd Numbers are NOT Available" 114 XE7 T ١:٢٠ ص أربعاء ١٥ أبريل +0 4. Method name: largest OddNumber. Parameters: int a[] Return: String Logic: finds and retums the largest odd number in the array a. If odd numbers cannot be found, this method should return the following text "Odd Numbers are NOT Available" Hint: you need to use String.valueOf(largest Num), if you find the largest odd number. 5. Method name: smallestOddNumber. Parameters: int a[] Return: String чер Logic: finds and returns the smallest odd number in the array a. If odd numbers cannot be found, this method should return the following text "Odd Numbers are NOT Available". Hint: you need to use String.valueOf(smallestNu odd number. 6. Method name: countMultipleOfNumbe Parameters: int a[] Return: int Logic: counts the numbers that returns the total cour Write the necessary code you find the smallest visible by number 5 in the array a and main method that tests all the described methods and clearly prints out the returned results in the format shown below: Sample output: There are 5 odd numbers The sum of odd numbers is 39 The average of odd numbers is 4.33 The largest odd number is 15 The smallest odd number is 3 There are 3 numbers dividable by 5

check_circle الجواب — حل مفصل خطوة بخطوة

hourglass_top