Exercise One: (6.3.7 Inserting an element, Sorted Array) This exercise is the extension of IC assignment # 12, Exercise 5 (Wednesday). • Declare an integer array of size 5. I am keeping the size 5 for simplicity. You can pick any size. • Fill the array with all positive numbers until user enters -1 (sentinel, not part of the calculation) to stop OR array gets full. • Display the original array, entered by the user. • Display the sorted array. Use Arrays.sort(arrayName, O, currentSize) Method. • Then ask the user, what number s/he wants to enter? • If the array is full, display the message, "Array is full, you can't add any more numbers". • If the array is partially filled, add the number by maintaining the order in the array. • NOTE: Do no create any new array. Algorithm: • This is a sorted array; you can't add the number at the last. • You need to find the position where you can enter the number. (Feel free to use linear search or Binary search) • then move all the elements to the right. • Enter the new number at the current position. Sample Output-1: Enter scores to fill the array, enter -1 to quit: Enter your number: 3 Enter your number: 7 Enter your number: 1 Enter your number: 3 Enter your number: 5 Array, entered by the user: 3, 7, 1, 3, 5 Sorted Array: 1 3 3 5 7 What number you want to add in this array: 2 Sorry, Array is full you can't add any more number. Sample Output-2: Enter scores to fill the array, enter -1 to quit: Enter your number: 6 Enter your number: 3 Enter your number: 5 Enter your number: -1 Array, entered by the user: 6, 3, 5 Sorted Array : 3 5 6 What number you want to add in this array: 4 *After adding 4 in the Array, here is new array. ** 3 456

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%
Exercise One: (6.3.7 Inserting an element, Sorted Array)
This exercise is the extension of IC assignment #12, Exercise 5 (Wednesday).
• Declare an integer array of size 5. I am keeping the size 5 for simplicity. You can pick any size.
• Fill the array with all positive numbers until user enters -1 (sentinel, not part of the calculation) to stop OR array gets full.
• Display the original array, entered by the user.
• Display the sorted array. Use Arrays.sort(arrayName, 0, currentSize) Method.
• Then ask the user, what number s/he wants to enter?
• If the array is full, display the message, "Array is full, you can't add any more numbers".
• If the array is partially filled, add the number by maintaining the order in the array.
• NOTE: Do no create any new array.
Algorithm:
• This is a sorted array; you can't add the number at the last.
• You need to find the position where you can enter the number. (Feel free to use linear search or Binary search)
• then move all the elements to the right.
• Enter the new number at the current position.
Sample Output-1:
Enter scores to fill the array, enter -1 to quit:
Enter your number: 3
Enter your number: 7
Enter your number: 1
Enter your number: 3
Enter your number: 5
Array, entered by the user: 3, 7, 1, 3, 5
Sorted Array: 1 3 3 5 7
What number you want to add in this array: 2
Sorry, Array is full you can't add any more number.
Sample Output-2:
Enter scores to fill the array, enter -1 to quit:
Enter your number: 6
Enter your number: 3
Enter your number: 5
Enter your number: -1
Array, entered by the user: 6, 3, 5
Sorted Array: 3 5 6
What number you want to add in this array: 4
****After adding 4 in the Array, here is new array. ****
3 4 5 6
Transcribed Image Text:Exercise One: (6.3.7 Inserting an element, Sorted Array) This exercise is the extension of IC assignment #12, Exercise 5 (Wednesday). • Declare an integer array of size 5. I am keeping the size 5 for simplicity. You can pick any size. • Fill the array with all positive numbers until user enters -1 (sentinel, not part of the calculation) to stop OR array gets full. • Display the original array, entered by the user. • Display the sorted array. Use Arrays.sort(arrayName, 0, currentSize) Method. • Then ask the user, what number s/he wants to enter? • If the array is full, display the message, "Array is full, you can't add any more numbers". • If the array is partially filled, add the number by maintaining the order in the array. • NOTE: Do no create any new array. Algorithm: • This is a sorted array; you can't add the number at the last. • You need to find the position where you can enter the number. (Feel free to use linear search or Binary search) • then move all the elements to the right. • Enter the new number at the current position. Sample Output-1: Enter scores to fill the array, enter -1 to quit: Enter your number: 3 Enter your number: 7 Enter your number: 1 Enter your number: 3 Enter your number: 5 Array, entered by the user: 3, 7, 1, 3, 5 Sorted Array: 1 3 3 5 7 What number you want to add in this array: 2 Sorry, Array is full you can't add any more number. Sample Output-2: Enter scores to fill the array, enter -1 to quit: Enter your number: 6 Enter your number: 3 Enter your number: 5 Enter your number: -1 Array, entered by the user: 6, 3, 5 Sorted Array: 3 5 6 What number you want to add in this array: 4 ****After adding 4 in the Array, here is new array. **** 3 4 5 6
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 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
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education