Answered step by step
Verified Expert Solution
Question
1 Approved Answer
in c++ please do all requirements for this code Thank you. Children leam how to sort items in order at an early age. They learn
in c++
Children leam how to sort items in order at an early age. They learn how to move items down to make room for an item being inserted into the middle of their puzzle. The steps are the same when shifting items in an array! In this assignment, you will write a program that uses arrays to represent sets of posilive integers and manipulates those arrays: You will: 1. Shufle two user-entered set of numbers in ascending order into their respective arrays 2. Count the number of elements in the array and insert that number as the zeroth element 3. Search the two organized arrays for intersecting elements (numbers that occur in both arrays) 4. Delete the matching (intersecting) elements found in step 3 from the first array only and update count Atter completing this assignment you will be able to: - Shift elements in an array to insert or delete elements - Use a for loop to manipulate the array without going out of bounds - Pass an array and the size to a function and manipulate the array Important Information - A set of numbers is a collection of numbers, called elements. The set can be either a finite collection or an infinite collection of numbers. One way of denoting a set, called roster notation, is to us. "fi and 3 . With the elements separated by commas: for instance, the set {3,31,7, p) contains the elements 3,31,7, and 5 . The zeroth element the element with array index 0 ) of each array will indicate the number of elemente For example in the set {3,31,7,53 the zeroth element will be 3 - 3 indicating theic de 3 intal elements in the set. - "Intersecting elements" are numbers that occk in boti s ts For example. if S et A={1,3. 5,6,8,7,9} and Set B={5,2,4,7, then the interseding elemenis are {5,7} - - Both arrays can hold a maximum nurnber of 20 elemients, CAP=20. Set an integer constant for CAP - You may not use ariy more lempotary arays to help you solva this problern. (But you may dedare as many simple variables as you like, such as int5.) You also may not use any other data structures or complex types such as strings, or other data structures such as Vector. Use only the concepts and functions we have learned 50 far. - You may not use any Sorting algonthims. - Your program must have function prototypes. Place the prototypes for your functions globally, after your tincludes. All functions must be implemented after main0. - Use constants where appropriate, for example - the capacity of the artay. - Try not to have any redundant code (repeated code) in your program. That is the purpose of functions: - See the Sample Pun in the Criteria for Success section below. Write functions to do the following. Each function should do ONLY what it is supposed to do, and no more unless specified. Ater writing each function, call the function in main0 to test it before writing the next function. Your main () function should: a. Declare 2 int arrays set1 and sel2 of capacity CAP (integer constant for CAP = 20) b. Call the readinput (int list []) function 2 times to populate the sets. c. Call findintersect (int set1[], int set2[], that finds the common numbers and calls the deleteNum (int [], int value) function to delete each number. Write welcome message (void function) Write a function called readinput (int list []) that does the following: a Reads an integer from the user and validates it to make sure it is a positive integer or -1. -1 ends the it. Use a loop to repeat until you get valid data from the user. Hint: Write a reauInt () Aimction to do this. My sampleA04 con has this. - The number of elements in the set should be entered into index 0 of the array; and make sure this number is always less than the capacity of the array, 20. Use the same function, send another int array to it and fill it with positive numbers in the same way. The number of elements in the set should be entered into index 0 of the array, and make sure this number is always less than the capacity of the array, 20. Welcome to my Set of Numbers program!! Enter numbers for set 1 on separate lines ( 1 to end): 641231 Your set 1 with 4 numbers ordered: 34612 Enter numbers for set 2 on separate lines ( 1 to end): 6 4 1 Your set 1 with 2 numbers ordered: 46 The new sets are: Set1: 312 Set2: 46 Thank you for checking c a set of Numbera program! Welcome to my Set of Numbers progratu!! Enter numbers for set 1 on sepazate 1 ines ( 1 to end): 9 4 12 3 16 d Invalid number! Please cry again! 1 Your set 1 with 6 numbers ordered: Enter numbers for set 2 on separate lines (-1 to end): \$ 12 9 Invalid number! Please try again! >> 16 1 Your set 1 with 3 numbers ordered: 91216 The new sets are: Set1: 3421 Set 2:91216 Thank you for checking out my Set of Numbers program: Complete all sections of your Algorithmic Design Document. Follow these Coding Construct Requirements: Do not use any vectors or containers for this program. Use only the concepts we have learned so far. Use only the 2 arrays for the 2 sets. No more extra arrays are needed. The first element in each array must hold the number of elements. Do not use any goto statements. You may not use any breaks or return statements inside any loops - you are allowed to use breaks inside a switch statement. All input data must be validated. For example, you should not accept any characters for numerical data types. Must not use any sorting algorithms, the numbers should be inserted in the right order. Must use all functions mentioned under Task - there should be no code redundancy. Print a welcome and goodbye message please do all requirements for this code
Thank you.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started