Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Develop a program that mimics some of the functionalities of an ArrayList in Java. Your program should maintain a pointer array of doubles and be

Develop a program that mimics some of the functionalities of an ArrayList in Java. Your program should maintain a pointer array of doubles and be able to perform the following functions:

-insert(int index, double num, double *&arr, int &size): Adds an element (num) to the array (arr) at a given position (index) and updates the size. You may allow the user to add to the immediate end of the array (at position n+1 for an array of n elements) but not past. You should print an error message if they try to print beyond these bounds.

- remove(int index, double *&arr, int &size): Removes an element from the array (arr) at a given position (index) and updates the size.

If index is out of the bounds of the array then an error message should be printed.

-get(int index, double *arr, int size): Returns the element at the given position (index). Should check if the index given is outside the bounds of the array. If it is out of bounds an error message should be printed.

-clear(double *&arr, int &size): Clears all elements of the array (arr) and updates the size (size) to be 0.

-find(double num, double *arr, int size): Returns the first index in which a given element (num) is found in the array (arr). If not found -1 is returned.

-equals(double *arr1, int size1, double *arr2, int size2): Returns true if the contents of the two arrays are equal and false if they are not equal.

-init(double *arr, int size): Populates the elements of the array (arr) with input from the user (or via file redirection).

-print(double *arr, int size): Prints the elements of the array.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo

1st Edition

0763733148, 978-0763733148

More Books

Students also viewed these Databases questions

Question

What is DDL?

Answered: 1 week ago