Question

Array Class Assignment

This is a two-part assignment. It is better to submit the files for both parts when you are done than to submit part 1 first and part 2 later.

In the Array.h file includes the class definition and member functions implementations.

PART 1

Write And Test An Array Class [Array.TestDriver.cpp]

Write a data structures class. The resulting class can be used in any program in place of a C++ array, in case you want the advantages of range safety and built-in size tracking.

Requirements. Write Array.TestDriver.cpp, includes your class Array declaration before main() function, all member function implementations after the main() function, and fully tested in it. Write the public interface exactly as specified below -- do not add to, or change the public interface as specified.

  1. Write the class for an array of 100 int values, all initialized to the default int value, zero. That means you need a main constructor.

  2. Include a square bracket getter and a setter, both with index range-checking, returning whatever value you wish, if out of range.

  3. Include a getter named Array::capacity( ) to return the data structure's capacity.

PART 2

Write An Array Application [MyArray.cpp]
Write MyArray.cpp includes your class Array declaration before main() function. All member functions implementation after the main() function.

The app lets its user enter as many values as they like, and when that process is completed, lets the user look up values by matching index.

In a loop, the app should prompting the user to enter a pair of numbers on the same line: a whole number index and its corresponding whole- number value. Do not validate input in the app, because your template should handle out-of-range indexes, and it should allow overwriting an already-entered index. Quit the loop when an uppercase or lowercase Q is entered for either the index or the value. Indexes can be entered in any order -- they don't have to start with zero and go up by one thereafter. It's whatever the user enters.

Your app should keep track of which indexes got entered. Use a second Array for that, with whatever integer codes you wish to distinguish used indexes from those never used.

After all data entry is complete, the app should:

  1. output how many (unique) indexes got entered,

  2. output the list of all used indexes and their values, per the example below, and

  3. implement an event-controlled loop that prompts for an index value and outputs whether the index is in use or not, and if in use, what is the value stored for that index. Loop until the user elects to stop by entering uppercase or lowercase Q.

Here's a sample of how this should work (user input in blue):

  Input an index and a value [Q to quit]:   Input an index and a value [Q to quit]:   Input an index and a value [Q to quit]:   Input an index and a value [Q to quit]: x  Input an index and a value [Q to quit]:   Input an index and a value [Q to quit]:   Input an index and a value [Q to quit]:   Input an index and a value [Q to quit]:   You stored this many values: 4
  The index-value pairs are:

    0 => 17
    4 => 100
    5 => 300
    33 => 120

  Input an index for me to look up [Q to quit]:   Found it -- the value stored at 33 is 120
  Input an index for me to look up [Q to quit]:   I didn't find it
  Input an index for me to look up [Q to quit]:   I didn't find it
  Input an index for me to look up [Q to quit]:

Design the prompts and the output formatting as you like.

And remember the identification comment code block and the identification cout code block!

 

Submission: Total two files to submit - two cpp files from both parts. No header file!


0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
Array Class Assignment
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • Stuck on this computer science assignment Write a program that demonstrates binary searching through an array...

    Stuck on this computer science assignment Write a program that demonstrates binary searching through an array of strings and finding specific values in an corresponding parallel double array. In all cases your output should exactly match the provided solution.o. Provided files: Assignment.cpp - starter assignment with function prototypes companies.txt - file for program to read. earnings.txt - file for program to read. Input1.txt Input2.txt - Test these inputs out manually, or use stream redirection Input3.txt - These inputs are based...

  • Write a Java program that will create an array of Strings with 25 elements. Input Strings...

    Write a Java program that will create an array of Strings with 25 elements. Input Strings from the user and store them in the array until either the user enters “quit” or the array is full. HINT: the sentinel value is “quit” all lowercase. “Quit” or “QUIT” should not stop the loop. HINT: you have to use the equals method (not ==) when you are comparing two Strings. After the input is complete, print the Strings that the user entered...

  • Array-based Queue Lecture 6 Two Class Exercises | Class Exercise #1 - Create an array-based queue that holds value...

    Array-based Queue Lecture 6 Two Class Exercises | Class Exercise #1 - Create an array-based queue that holds values of double data type. 1.) Create a program that produces the following output OUTPUT: Q Quit Enter your choice: e Enter an item: 1.1 E Enqueue D Dequeue s-show queue ← showMenuO function called in main) OQuit // screen clears-.. continue enqueuing.screen clearing with each iteration Enter your choice: e Queue is full. E Enqueue D Dequeue s Show queue 0...

  • Open a new file in your text editor, and start a class that will demonstrate a...

    Open a new file in your text editor, and start a class that will demonstrate a working two-dimensional array: import java.util.Scanner; class TwoDimensionalArrayDemo { public static void main(String[] args) { 2. Declare a three-by-three array of integers. By default, the elements will all be initialized to 0. int[][] count = new int[3][3]; 3. Declare a Scanner object for input, variables to hold a row and column, and a constant that can be used to indicate when the user wants to...

  • Write a C program Design a program that uses an array to store 10 randomly generated...

    Write a C program Design a program that uses an array to store 10 randomly generated integer numbers in the range from 1 to 50. The program should first generate random numbers and save these numbers into the array. It will then provide the following menu options to the user: Display 10 random numbers stored in the array Compute and display the largest number in the array Compute and display the average value of all numbers Exit The options 2...

  • Write a set of C++ programs to implement the following operations listed in the menu function...

    Write a set of C++ programs to implement the following operations listed in the menu function below. a. File: main.cpp - contains the main function b. File: arrayhw.cpp – contains the 1D array function implementations c. File: arrayhw.h – contains the 1D array function prototyped declarations d. May create other files to implement any other needed function The main menu function should display the following: Main Menu, 1D Array Functions Enter a number to choose one of the following actions:...

  • I need help making this work correctly. I'm trying to do an array but it is...

    I need help making this work correctly. I'm trying to do an array but it is drawing from a safeInput class that I am supposed to use from a previous lab. The safeInput class is located at the bottom of this question I'm stuck and it is not printing the output correctly. The three parts I think I am having most trouble with are in Bold below. Thanks in advance. Here are the parameters: Create a netbeans project called ArrayStuff...

  • Following the instruction This is c++ programming Lab Tasks: 1. Define a dynamic array class in...

    Following the instruction This is c++ programming Lab Tasks: 1. Define a dynamic array class in DynamicArray .h and DynamicArray.cpp files, according to the following UML class diagram: DynamicArray - int arrySize; - int currentSize; int* arrayPtr; + DynamicArray(int size) // Explicit constructor, which you define- allocate space in dynamic memory for an integer array of the given size. + DynamicArray) // Explicit destructor, which you define-de allocate dynamic memory. + additem(int item): bool // Set the value of the...

  • Create a class called Student. This class will hold the first name, last name, and test...

    Create a class called Student. This class will hold the first name, last name, and test grades for a student. Use separate files to create the class (.h and .cpp) Private Variables Two strings for the first and last name A float pointer to hold the starting address for an array of grades An integer for the number of grades Constructor This is to be a default constructor It takes as input the first and last name, and the number...

  • Assignment Input from the user 9, 64-bit, floating-point values as a 3x3, row-major, multi-dimensional array. This...

    Assignment Input from the user 9, 64-bit, floating-point values as a 3x3, row-major, multi-dimensional array. This will be the 3x3 matrix. Then, input 3, 64-bit, floating-point values. This will be a single-dimensional array and is the vector. Your program will simply ask the user to enter matrix values. Remember, there are 9 of these, but they need to be stored into a 3x3 multi-dimensional array (row-major). Then, your program will ask for the vector values, which will be stored into...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT