Solved by Expert Tutors
This means that every student must ensure that neither a soft copy nor a hard copy of their work gets into the hands of another student.
Solved by Expert Tutors
Question

I am so confused on how to do this.... Any help???

CSE 110 - Assignment 7 Maximum Points: 20 What this Assignment Is About: Arrays Classes Searching Your programming assignments require individual work and effort to be of any benefit. Every student must work independently on his or her assignments. This means that every student must ensure that neither a soft copy nor a hard copy of their work gets into the hands of another student. Sharing your assignments with others in any way is NOT permitted. Violations of the University Academic Integrity policy will not be ignored. The university academic integrity policy is found at http://www.asu.edu/studentlife/judicial/integrity.html Use the following Coding Guidelines: Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc). Keep identifiers to a reasonably short length. Use upper case for constants. Use title case (first letter is upper case) for classes. Use lower case with uppercase word separators for all other identifiers (variables, methods, objects). Use tabs or spaces to indent code within blocks (code surrounded by braces). This includes classes, methods, and code associated with ifs, switches and loops. Be consistent with the number of spaces or tabs that you use to indent. Use white space to make your program more readable. Use comments after the ending brace of classes, methods, and blocks to identify to which block it belongs. Assignments Documentation: At the beginning of each programming assignment you must have a comment block with the following information: /*------------------------------------------------------------------------- // AUTHOR: your name // FILENAME: title of the source file // SPECIFICATION: description of the program // YOUR Lab Letter and Name of the TA for your Closed lab // FOR: CSE 110- homework #- days and time of your class // TIME SPENT: how long it took you to complete the assignment //----------------------------------------------------------------------*/
Background image of page 1
Part 1: Written Exercises: (5 points) Consider the following array: int[] a = { 3, 5, , 8, 10 , 12}; Write the contents of the array a after the following loops. Use the original data above for each question. (1 Point each) a) for (int i = 1; i < 6; i++) { a[i] = a[i - 1]; } b) for (int i = 5; i > 0; i--) { a[i] = a[i - 1]; } c) for (int i = 0; i < 5; i++) { a[i] = a[i + 1]; } d) for (int i = 4; i >= 0; i-=2) { a[i] = a[i + 1]; } e) for (int i = 1; i < 6; i++) { a[i] = a[5 - i]; } Part 2: Programming: (15 points) Your assignment is to create a class called Collection in a file called Collection.java . (there is no main method in this class). A class Collection has an array of integers and a count (integer) as instance variables. The variable count keeps track of how many integers are store in the array. The variable name for the array of integers is numArray . Note: You need to distinguish the array size (capacity) and "count" that keeps track of numbers added to this array so far. The class Collection must include the following constructor and methods. (If your class does not contain any of the following methods, points will be deducted.) Method Description of the Method public Collection(int arraySize) It constructs an empty Collection object with an array capacity specified by the integer parameter "arraySize". private int search(int searchingNum) It returns the index of the number specified by the parameter is located. If the number is not found, it returns -1. It is a service (helper) method. public boolean add (int numberToAdd) The method checks if the integer specified by the parameter exists in the array (This can be done using the search method to see if it returns -1 or not) and also checks if the array has not reached its capacity. If both are satisfied, the number is added to the array at the smallest available index. If the array reached its capacity, double its size by calling the method doubleArrayCapacity() and add the number. If the number is added successfully, then the method returns true. If the number already exists in the array, the new number will not be added, and the method returns false. public boolean remove(int numberToRemove) The method checks if the integer specified by the parameter exists in the array (This can be done using the search method to see if it returns -1 or not) and if it does, it deletes the number by shifting numbers to the left and it returns true. Otherwise, it returns false. public int getCount() Returns the number of elements added so far to the array numArray. public int[] rotate (int n) The method takes an integer rotation amount, n. The method creates a new array with the items of numArray moved forward by n positions. Elements that are rotated off the array will appear at the end. For example, suppose numArray contains the following items in sequence: 1 2 3 4 5 6 7 After rotating by 3, the elements in the new array will appear in this sequence: 4 5 6 7 1 2 3
Background image of page 2
Show entire document

Step-by-step answer

gue vel laoreet ac, dict


Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce

Subscribe to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Let our 24/7 Computer Science tutors help you get unstuck! Ask your first question.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes