
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Write a Java program to implement a one-dimensional integer array of any size, add its elements and test whether the final sum is an odd or even.
Sample array1: 25 3 80 9 25
Sample output: Even
Sample array2: 24 13 7 8 25
Sample output: Odd
Expert Solution

arrow_forward
Step 1
logic:-
read size of array from user i.e n
take elements of array using iternation from i=0 to n
use another loop from i=0 to n
sum=sum+arr[i]
check if sum%2==0
display “even”
else
display “odd”
end.
Step by stepSolved in 3 steps with 1 images

Knowledge Booster
Similar questions
- WRITE A PROGRAM IN JAVA Define a 2 dimensional arrays of doubles (3 rows by 3 columns) and read values from the user. • Print the numbers entered by the user in row major order • Print the numbers entered by the user in column major orderarrow_forwardCheck if Array Elements are Consecutive in Java. Given an array, we need to check if array contains consecutive elements. For example: Input: array[] = {5, 3, 4, 1, 2} Output: true As array contains consecutive elements from 1 to 5 Input: array[] = {47, 43, 45, 44, 46} Output: true As array contains consecutive elements from 43 to 47 Input: array[] = {6, 7, 5, 6} Output: false As array does not contain consecutive elements.arrow_forwardwrite a java-like pseudocode printing how many times integer x appears in an array. the array values are (1,2,1,3,1,1) and x=1.arrow_forward
- Write a Java program to prompt the user to enter an integer n between 1 and 20 both inclusive and (error check is required), then create an array arr of size n. The program then will fill up the integer array with powers of 2, so first element will be 20 , second element will be 2^1 , third element will be 2^2 , forth element will be 2^3 .......... and the last element will be 2n^-1.arrow_forwardWrite a Java program that obtains products' numbers (array named products[]), and allows the user to perform array’s operations using the following methods: initializeArray() – to initialize the array’s elements printArray()- to print array’s elements searchArray()- to search and determine if a product exists in the array removeArray()- to remove an array element and display the new array The program also includes: One class named 4 One instance variable named size Your program should include the following code statements in the ArrayApp class:arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education