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
  • I have a programming assignment for a introductory c++ class and I am really struggling writing...

    I have a programming assignment for a introductory c++ class and I am really struggling writing this program. Below are the assignment requirements, I am unable to use vectors in stl and I keep getting a ton of compiling errors. Thank you chegg experts. You have really helped me out this semester. Your responses and code has cleared up so many issues ive had. Description The purpose of this challenge is to employ the use of basic functions and arrays....

  • 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...

  • LINUX question Write a shell script called findcapital to find the capital of a state, given...

    LINUX question Write a shell script called findcapital to find the capital of a state, given the state. Create a function called read_state that reads your capitals file into an array. Create another function called find_it that checks if the user's inputted state matches one of the elements in the array. It matches, tell the user the capital. The main part of the program will execute the read_states function, get the input, then execute the find_it function. Add the following...

  • 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...

  • Write code in static void main method class, which creates a boolean array called flags, size...

    Write code in static void main method class, which creates a boolean array called flags, size 10, and using a for loop sets each element to alternating values (true at index zero, false at index one Write code in a static void main method class, which creates a float array called sales, size 5, uses an initializer list to instantiate its elements with positive values having two decimal places (example 7.25), and using a for loop reads those values of...

  • 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...

  • 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...

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