
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
![Instructions
CPS 150 Lab Project 25: Rotating
Java Arrays (Java Arrays With
Methods)
This lab project is due on Monday, April
11, 2022 at 12:30 pm.
Write a method that is passed an array, x, of
doubles and an integer rotation amount, n.
The method creates a new array with the
items of x moved forward by n positions.
1. Create a new Eclipse project named
Lab_Project_25
2. Download the source code file
Array_Spinner.java and import it into
your Eclipse project.
3. Open the source code in Eclipse.
4. Add your name to the comment block at
the top of the file
5. Complete the rotate method as described
in the source code
Notes
Elements that are rotated off the array will
appear at the end. For example, suppose x
contains the following items in sequence:
1234567
After rotating by 3, the elements in y will
appear in this sequence:
4567123
Array x should be left unchanged by your
program. Be sure to test your program with
different array sizes and rotation amounts
(see Sample Run, below).
Sample Run (user input in color):
Before rotation:
x[0]:
8.0
x[1]:
4.0
x[2]:
5.0
x[3]:
21.0
x[4]: 7.0
x[5]:
9.0
x[6]:
18.0
x[7]:
2.0
x[8]:
100.0
After rotation:
y[0]: 21.0
y[1]:
y[2]:
y[3]:
y[4]:
У [5]:
y[6]:
y[7]:
y[8]:
7.0
9.0
18.0
2.0
100.0
8.0
4.0
5.0
What Do I Hand In?
• Attach your completed source code
(Array_Spinner.java) file below.
Then click Submit.](https://content.bartleby.com/qna-images/question/44ae875a-f598-455b-b111-f9246b312123/267dee25-c0e7-41d7-b8d1-5c0cc730f9df/r10ngn8_thumbnail.jpeg)
Transcribed Image Text:Instructions
CPS 150 Lab Project 25: Rotating
Java Arrays (Java Arrays With
Methods)
This lab project is due on Monday, April
11, 2022 at 12:30 pm.
Write a method that is passed an array, x, of
doubles and an integer rotation amount, n.
The method creates a new array with the
items of x moved forward by n positions.
1. Create a new Eclipse project named
Lab_Project_25
2. Download the source code file
Array_Spinner.java and import it into
your Eclipse project.
3. Open the source code in Eclipse.
4. Add your name to the comment block at
the top of the file
5. Complete the rotate method as described
in the source code
Notes
Elements that are rotated off the array will
appear at the end. For example, suppose x
contains the following items in sequence:
1234567
After rotating by 3, the elements in y will
appear in this sequence:
4567123
Array x should be left unchanged by your
program. Be sure to test your program with
different array sizes and rotation amounts
(see Sample Run, below).
Sample Run (user input in color):
Before rotation:
x[0]:
8.0
x[1]:
4.0
x[2]:
5.0
x[3]:
21.0
x[4]: 7.0
x[5]:
9.0
x[6]:
18.0
x[7]:
2.0
x[8]:
100.0
After rotation:
y[0]: 21.0
y[1]:
y[2]:
y[3]:
y[4]:
У [5]:
y[6]:
y[7]:
y[8]:
7.0
9.0
18.0
2.0
100.0
8.0
4.0
5.0
What Do I Hand In?
• Attach your completed source code
(Array_Spinner.java) file below.
Then click Submit.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images

Knowledge Booster
Similar questions
- Define a class called Book. This class should store attributes such as the title, ISBN number, author, edition, publisher, and year of publication. Provide get/set methods in this class to access these attributes. Define a class called Bookshelf, which contains the main method. This class should create a few book objects with distinct names and store them in an ArrayList. This class should then list the names of all books in the ArrayList. Enhance the program by providing a sort function, which will sort the books in ascending order of their year of publication. Create a few more Bookobjects with the same names but with different edition numbers, ISBNs, and years of publication. Add these new Book objects to the ArrayList, and display the book list sorted by book name; for duplicate books of the same name, sort the list by year of publication. (Hint: You will need to define a comparator class that takes two Book objects as parameters of the compareTo This method should do a two-step…arrow_forwardcan you explain the code with comments import randomrandom.seed = 1class array: def __init__(self, valuelist): self.atos = valuelist.copy() # this variable is the array that holds the data def additem(self, value): # adds a item to the array self.atos.append(value) def printarray(self): # prints the self.atos print(self.atos) def __contains__(self, key): # To test the binary search change the "__linearsearch" to "__binsearch" return self.__binsearch(key) def __linearsearch(self, key): # Implements the linear search to find an item in the array for item in self.atos: if item == key: return True return False def __binsearch(self, key): temp = sorted(self.atos) # Implements the binary search to find an item in the array temp. This implements an iterative bin search algorithm. low = 0 high = len(temp) - 1 while low <= high:…arrow_forwardUsing Eclipsearrow_forward
- Image one is my file. Image 2 is my code(already have method 1 and 2) For my method 3, I want to write A method to find the index of the maximum value in an array takes one parameter, an array of integers returns the index at which the maximum value of the array occurs If the maximum value occurs multiple times, you may return the index of any occurrencearrow_forwardHello! I need some help with my Java homework. Please use Eclipse Please add comments to the to program so I can understand what the code is doing and learn Create a new Eclipse project named so as to include your name (eg smith15 or jones15). In this project, create a new package with the same name as the project. In this package, write a solution to the exercise noted below. Implement the following method that returns the maximum element in an array: public static <E extends Comparable<E>> E max(E[] list) Write a test program that generates 10 random integers, invokes this method to find the max, and then displays the random integers sorted smallest to largest and then prints the value returned from the method. Max sure the the last sorted and returned value as the same!arrow_forwardJava Task 1 Create an object of type FitnessExperiment that stores an array of StepsFitnessTracker, DistanceFitnessTracker, and HeartRateFitnessTracker objects. You could use code such as the following to initialise the array containing the fitness tracker measurements: FitnessTracker[] trackers = { new StepsFitnessTracker("steps", new Steps(230)), new StepsFitnessTracker("steps2", new Steps(150)), new StepsFitnessTracker("steps2", new Steps(150)), new HeartRateFitnessTracker("hr", new HeartRate(80)), new HeartRateFitnessTracker("hr", new HeartRate(80)) }; In the FitnessExperiment class, complete the implementation of the methods named getTotalSteps()and printExperimentDetails(). The comments in the code specify how they should operate and provide you with additional hints to get you started. You can use the method getSteps()in StepsFitnessTracker, but think how you will know the real type of each object in the array of fitness trackers (trackers in the example above). FitnessTracker…arrow_forward
- ARRAYS Please provide the source code and the screenshot of the output using Java eclipse.arrow_forwardIn this project you will generate a poker hand containing five cards randomly selected from a deck of cards. The names of the cards are stored in a text string will be converted into an array. The array will be randomly sorted to "shuffle" the deck. Each time the user clicks a Deal button, the last five cards of the array will be removed, reducing the size of the deck size. When the size of the deck drops to zero, a new randomly sorted deck will be generated. A preview of the completed project with a randomly generated hand is shown in Figure 7-50.arrow_forwardGuide to working through the project Steps: Write the GradeBook constructor that reads student information from the data file into the ArrayList roster). For now, ignore the grades. Test your GradeBook class before proceeding to the next step. Create the Grade class. Test your Grade class before proceeding to the next step. Modify the Student class to include an ArrayList of Grade. Test the Student class before proceeding to the next step. Finish writing the GradeBook constructor to process the grades as they are read in from the data file. Test the GradeBook class before proceeding to the next step. Add additional functionality to the GradeBook and Student classes one method at a time. Here is Grade.jave code is shown below. public class Grade { // TODO: complete this class as described in this task write-up } GradeBook Class The GradeBook class has a single instance variable roster, an ArrayList of Student. This class performs all operations related to the scores of all…arrow_forward
- The contents of the array below represent a maxHeap. What would be the contents of the array after a deletion. Briefly explain how the deletion is done. 60 20 30 5 10 15 25arrow_forwardMain difference between an array and an ArrayList is that an ArrayList can store more data types an ArrayList can store more elements an ArrayList executes faster for retrieval and insertion an ArrayList takes care of the memory management automatically an ArrayList uses positions and an array uses indicesarrow_forwardIn javacode: Use ArrayList to create an array called myAL of type integer. --Fill the array with the values 5, 10, 15, 22, 33. --Print the array (use enhanced for loop). --Insert the value 25 between 10 and 15 and print the array.--Remove 2 elements on index 1 and 3 and then print the array.--Print if the array contains the value 123 or not.--Print the index of the element 22.--Print the size of the array.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY