# Assignment 8 solution

\$30.00

Category:

## Description

Preparation

The core material is in 7.2 – 7.4 and 7.7. Make sure you understand every word in these sections. 7.9, 7.13, and 7.14 contain other important concepts, but they aren’t core. There’s a decent chance you won’t need them in this class.

7.1, 7.5, 7.6, 7.8, 7.10, 7.11, and 7.12, 7.15, and 7.16 contain examples to help you understand the material and a few concepts that would be good to know but that I won’t hold you directly responsible for in this class. Reading them may help you do better on the assignments and tests if they help you to understand the material. However, if you are pressed for time, you could just read them lightly.

For Credit

Assignment 8.1 [15 points]

Complete all of the MyProgrammingLab exercises for chapter 7.

Assignment 8.2 [80 points]

Write a program that reads in non-negative integers and stores and displays distinct numbers (i.e., if a number appears multiple times, it is stored and displayed only once). Your program should allow up to 1000 distinct numbers to be stored and displayed. Use the following algorithm (this is required!): Read each number and store it in an array if it is new. If the number is already in the array, ignore it. The user will indicate that they are done entering numbers by entering a negative number. Here is a sample run:

Enter a non-negative integer (negative to quit): 1

Enter a non-negative integer (negative to quit): 2

Enter a non-negative integer (negative to quit): 3

Enter a non-negative integer (negative to quit): 2

Enter a non-negative integer (negative to quit): 1

Enter a non-negative integer (negative to quit): 6

Enter a non-negative integer (negative to quit): 3

Enter a non-negative integer (negative to quit): 4

Enter a non-negative integer (negative to quit): 5

Enter a non-negative integer (negative to quit): 2

Enter a non-negative integer (negative to quit): -4

You entered:

1 2 3 6 4 5

To get credit for this assignment you must use appropriate decomposition! You should have a method to read the numbers and a method to print the resulting array. The method that reads the numbers should call an additional method that returns a bool value indicating whether a number is already in the array. At the conclusion of the call to the method that reads the numbers, the array MUST contain only distinct numbers.

Additionally, you must not sort the array. The numbers must appear in the same order in which they were typed.

Execute the program and copy/paste the output into the bottom of the source code file, making it into a comment. Send an email to ta.sanmateo@gmail.com with the subject “CIS 254 a8”. Attach your source code file(s) to the email. In the body of the email let me know whether the programs work as required.

Keep in mind that if your code does not compile you will receive a 0.

Note that the gmail email account is for homework submission only. The account is not monitored for any other purpose.

Assignment 8.3 [5 points]

Participate in the lesson 8 discussion. This could involve asking a question, answering another student’s question, giving an example of something that you struggled with and then overcame (or didn’t!), giving an example of something you found particularly cool, or any other constructive way you can think of to participate.

error: Content is protected !!