Big Java, Binder Ready Version: Early Objects
Big Java, Binder Ready Version: Early Objects
6th Edition
ISBN: 9781119056447
Author: Cay S. Horstmann
Publisher: WILEY
Question
Book Icon
Chapter 7, Problem 10PE

a.

Program Plan Intro

To swap the first and last elements in the array

Program plan:

  • In the file SwapFirstLast.java”, import necessary package and create a class SwapFirstLast”,
    • Define the method “swapFirstAndLast()” to swap the first and last elements in an array.
    • Define the method.
      • Create an array.
      • Create an object for “SwapFirstLast”.
      • Create a test array containing random numbers.
      • Call the method “swapFirstAndLast()” to perform swap.

b.

Program Plan Intro

A test program for a method “shiftRight()”

Program plan:

  • In the file RotateRight.java”, import necessary package and create a class RotateRight”,
    • Define the method “shiftRight()” to shift all elements of the array to the right by one and move the last element into the first position.
      • Define the method “main()”.
      • Create an array.
      • Create an object for “RotateRight”.
      • Create an object for “Random”.
      • Create a test array containing random numbers.
      • Call the method “shiftRight()”.

c.

Program Plan Intro

A test program for a method “replaceEven()”

Program plan:

  • In the file ReplaceEven.java”, import necessary package and create a class ReplaceEven”,
    • Define the method “replaceEven()” to replace all even elements with “0”.
    • Define the method “main()”.
    • Create an array.
    • Create an object for “ReplaceEven”.
    • Create an object for “Random”.
    • Create a test array containing random numbers.
    • Call the method “replaceEven()”.

d.

Program Plan Intro

A test program for a method “replaceWithLargestNeighbor()”

Program plan:

  • In the file ReplaceWithLargestNeighbor.java”, import necessary package and create a class ReplaceWithLargestNeighbor”,
    • Define the method “replaceWithLargestNeighbor()” to replace all elements except first and last by the largest of its "2" neighbors.
    • Define the method “main()”.
      • Create an array.
      • Create an object for “ReplaceWithLargestNeighbor”.
      • Create an object for “Random”.
      • Create a test array containing random numbers.
      • Call the method “replaceWithLargestNeighbor().

e.

Program Plan Intro

A test program for a method “removeMiddle()”

Program plan:

  • In the file RemoveMiddle.java”, import necessary package and create a class RemoveMiddle”,
    • Define the method “removeMiddle()” to remove the middle element if the length of the array is odd, or the middle two elements if the array length is even.
    • Define the method “main()”.
      • Create an array of odd size.
      • Create an object for “RemoveMiddle”.
      • Create an object for “Random”.
      • Create a test array containing random numbers.
      • Call the method “removeMiddle()” with an array of odd size.
      • Create an array of even size.
      • Create a test array containing random numbers.
      • Call the method “removeMiddle()” with an array of even size.

f.

Program Plan Intro

A test program for a method “moveEvenToFront()”

Program plan:

  • In the file MoveEvenToFront.java”, import necessary package and create a class MoveEvenToFront”,
    • Define the method “moveEvenToFront()” to move all even elements to the front.
    • Define the method “main()”.
      • Create an array of odd size.
      • Create an object for “MoveEvenToFront”.
      • Create an object for “Random”.
      • Create a test array containing random numbers.
      • Call the method “moveEvenToFront()”.

g.

Program Plan Intro

A test program for a method “getSecondLargest()”

Program plan:

  • In the file GetSecondLargest.java”, import necessary package and create a class GetSecondLargest”,
    • Define the method “getSecondLargest()” to return the second-largest element in the array.
    • Define the method “main()”.
      • Create an array of odd size.
      • Create an object for “GetSecondLargest”.
      • Create an object for “Random”.
      • Create a test array containing random numbers.
      • Call the method “getSecondLargest()” and print the output.

h.

Program Plan Intro

A test program for a method “inOrder()”

Program plan:

  • In the file InOrder.java”, import necessary package and create a class InOrder”,
    • Define the method “inOrder()” to return true if the array is recently sorted in increasing order.
    • Define the method “main()”.
      • Initialize the array with sorted and unsorted order.
      • Call the method “inOrder()” to check if the array is sorted or not.

i.

Program Plan Intro

A test program for a method “adjacentDupes()”

Program plan:

  • In the file AdjacentDupes.java”, import necessary package and create a class AdjacentDupes”,
    • Define the method “adjacentDupes()” to return  true if the array has two adjacent duplicate elements.
    • Define the method “main()”.
      • Create an array of adjacent and non-adjacent duplicate values.
      • Create an object for “AdjacentDupes”.
      • Call the method “adjacentDupes()” to check if the array has two adjacent duplicate elements.

j.

Program Plan Intro

A test program for a method “containsDuplicates()”

Program plan:

  • In the file ContainsDuplicates.java”, import necessary package and create a class ContainsDuplicates”,
    • Define the method “containsDuplicates()” to return  true if the array has duplicate elements.
    • Define the method “main()”.
      • Create an array of adjacent and non-adjacent duplicate values.
      • Create an object for “ContainsDuplicates”.
      • Call the method “containsDuplicates()” to check if the array has duplicate elements.

Blurred answer
Students have asked these similar questions
Please do not use any AI tools to solve this question. I need a fully manual, step-by-step solution with clear explanations, as if it were done by a human tutor. No AI-generated responses, please.
Obtain the MUX design for the function F(X,Y,Z) = (0,3,4,7) using an off-the-shelf MUX with an active low strobe input (E).
I cannot program smart home automation rules from my device using a computer or phone, and I would like to know how to properly connect devices such as switches and sensors together ? Cisco Packet Tracer 1. Smart Home Automation:o Connect a temperature sensor and a fan to a home gateway.o Configure the home gateway so that the fan is activated when the temperature exceedsa set threshold (e.g., 30°C).2. WiFi Network Configuration:o Set up a wireless LAN with a unique SSID.o Enable WPA2 encryption to secure the WiFi network.o Implement MAC address filtering to allow only specific clients to connect.3. WLC Configuration:o Deploy at least two wireless access points connected to a Wireless LAN Controller(WLC).o Configure the WLC to manage the APs, broadcast the configured SSID, and applyconsistent security settings across all APs.

Chapter 7 Solutions

Big Java, Binder Ready Version: Early Objects

Ch. 7.2 - Prob. 11SCCh. 7.2 - Prob. 12SCCh. 7.3 - Prob. 13SCCh. 7.3 - Prob. 14SCCh. 7.3 - Prob. 15SCCh. 7.3 - Prob. 16SCCh. 7.3 - Prob. 17SCCh. 7.3 - Prob. 18SCCh. 7.3 - Prob. 19SCCh. 7.4 - Prob. 20SCCh. 7.4 - Prob. 21SCCh. 7.4 - Prob. 22SCCh. 7.4 - Prob. 23SCCh. 7.4 - Prob. 24SCCh. 7.5 - Prob. 25SCCh. 7.5 - Prob. 26SCCh. 7.5 - Prob. 27SCCh. 7.5 - Prob. 28SCCh. 7.5 - Prob. 29SCCh. 7.6 - Prob. 30SCCh. 7.6 - Prob. 31SCCh. 7.6 - Prob. 32SCCh. 7.6 - Prob. 33SCCh. 7.6 - Prob. 34SCCh. 7.7 - Declare an array list of integers called primes...Ch. 7.7 - Prob. 36SCCh. 7.7 - Prob. 37SCCh. 7.7 - Prob. 38SCCh. 7.7 - Prob. 39SCCh. 7.7 - Prob. 40SCCh. 7.7 - Prob. 41SCCh. 7.8 - Prob. 42SCCh. 7.8 - Prob. 43SCCh. 7.8 - Prob. 44SCCh. 7 - Prob. 1RECh. 7 - Prob. 2RECh. 7 - Write a program that contains a bounds error. Run...Ch. 7 - Write a loop that reads ten numbers and a second...Ch. 7 - Prob. 5RECh. 7 - Consider the following array: int[] a = { 1, 2, 3,...Ch. 7 - Consider the following array: int[] a = { 1, 2, 3,...Ch. 7 - Prob. 8RECh. 7 - Write Java code for a loop that simultaneously...Ch. 7 - What is wrong with each of the following code...Ch. 7 - Write enhanced for loops for the following...Ch. 7 - Rewrite the following loops without using the...Ch. 7 - Rewrite the following loops using the enhanced for...Ch. 7 - What is wrong with each of the following code...Ch. 7 - For the operations on partially filled arrays...Ch. 7 - Trace the flow of the loop in Section 7.3.4 with...Ch. 7 - Prob. 17RECh. 7 - Prob. 18RECh. 7 - Trace the algorithm for removing an element...Ch. 7 - Give pseudocode for an algorithm that rotates the...Ch. 7 - Prob. 21RECh. 7 - Suppose values is a sorted array of integers. Give...Ch. 7 - A run is a sequence of adjacent repeated values....Ch. 7 - What is wrong with the following method that aims...Ch. 7 - You are given two arrays denoting x- and...Ch. 7 - Solve the quiz score problem described in Section...Ch. 7 - Prob. 27RECh. 7 - Develop an algorithm for finding the most...Ch. 7 - Write Java statements for performing the following...Ch. 7 - Prob. 30RECh. 7 - Section 7.7.7 shows that you must be careful about...Ch. 7 - True or false? All elements of an array are of the...Ch. 7 - How do you perform the following tasks with array...Ch. 7 - Prob. 34RECh. 7 - Prob. 35RECh. 7 - Prob. 36RECh. 7 - Write a program that initializes an array with ten...Ch. 7 - Modify the LargestInArray.java program in Section...Ch. 7 - Write a method sumWithoutSmallest that computes...Ch. 7 - Add a method removeMin to the Student class of...Ch. 7 - Prob. 5PECh. 7 - Write a method that reverses the sequence of...Ch. 7 - Write a program that produces ten random...Ch. 7 - Write a method that implements the algorithm...Ch. 7 - Prob. 9PECh. 7 - Prob. 10PECh. 7 - Consider the following class: public class...Ch. 7 - Add a method public boolean sameValues(Sequence...Ch. 7 - Add a method public boolean sameValues(Sequence...Ch. 7 - Prob. 14PECh. 7 - Prob. 15PECh. 7 - Add a method to the Table class below that...Ch. 7 - Given the Table class of Exercise E7.16, add a...Ch. 7 - Prob. 18PECh. 7 - Prob. 19PECh. 7 - Prob. 20PECh. 7 - Improve the program of Exercise E7.17 by adding...Ch. 7 - Consider the following class: public class...Ch. 7 - Prob. 23PECh. 7 - Prob. 24PECh. 7 - Prob. 1PPCh. 7 - Prob. 2PPCh. 7 - Prob. 3PPCh. 7 - Prob. 4PPCh. 7 - Prob. 5PPCh. 7 - Prob. 6PPCh. 7 - Prob. 7PPCh. 7 - Prob. 8PPCh. 7 - Prob. 9PPCh. 7 - Prob. 10PPCh. 7 - A pet shop wants to give a discount to its clients...Ch. 7 - Prob. 12PPCh. 7 - Prob. 13PPCh. 7 - Prob. 14PPCh. 7 - Prob. 15PPCh. 7 - Prob. 16PPCh. 7 - Prob. 17PPCh. 7 - Prob. 18PPCh. 7 - Prob. 19PPCh. 7 - Prob. 20PPCh. 7 - Prob. 21PPCh. 7 - Prob. 22PPCh. 7 - Prob. 23PPCh. 7 - Prob. 24PPCh. 7 - Prob. 25PP
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education