Parallel arrays:
Arrays are used to group related data types together. The elements in two arrays with different variables that are related to their position are known as parallel arrays.
Establishing relationship between two parallel arrays:
Consider two arrays named “strMonth []” and “intBonus []” arrays are declared as follows:
string strMonth[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
int intBonus[] = {25000, 26000, 27000, 29000, 31000, 34000, 36000, 37000, 38000, 40000, 41000, 45000};
Based on the above example, the relationship is established by using the same subscript for both the arrays. “strMonth[index]” have relationship on “intBonus[index]”. That is, the bonus amount of January month is 25000, February month is 26000, and so on.
Trending nowThis is a popular solution!
Chapter 8 Solutions
STARTING OUT W/PROGRAM.LOGIC...-TEXT
- (Statistics) Write a program that includes two functions named calcavg() and variance(). The calcavg() function should calculate and return the average of values stored in an array named testvals. The array should be declared in main() and include the values 89, 95, 72, 83, 99, 54, 86, 75, 92, 73, 79, 75, 82, and 73. The variance() function should calculate and return the variance of the data. The variance is obtained by subtracting the average from each value in testvals, squaring the values obtained, adding them, and dividing by the number of elements in testvals. The values returned from calcavg() and variance() should be displayed by using cout statements in main().arrow_forwardCreate a simple C++ Programarrow_forwardLooking for this in Python, please. Shopping list assignment (Parallel Array) Create three global variables with the proper data types: sub_totaltotal_pricesales_tax Sales tax is 9.5% Seven items minimum Create a shopping list (List, Tuple or Dictionary) of your choice (Items in list) Create a price list (Price for each item in shopping list) Create and print your parallel array (match each item to its price) Print the list with its index numbers Select one or more items from the shopping list using the index number Print your selected items with price Print sub total (base price of item(s) before tax) Print sales tax amount (before adding it into total price) Calculate and print total price with tax included. (this is what you would pay walking out the door) Round to two decimal pointsarrow_forward
- An array is a collection of similar data elements stored at contiguous memory locations. It is the simplest data structure where each data element can be accessed directly by only using its index number. The following is an array of unsorted numbers called NumArr. NumArr: 24 56 78 79 34 75 2 23arrow_forwardAssignment Write a program that reads a 2D array of chars, checks, and corrects each char within this array, and print out the corrected 2D array. First the program will read the row count (rowCount) and column count (columnCount) of the 2D array, both as int values. Then, the chars constituting the 2D array will be read on a row-by-row basis. After reading the 2D array, the program will check and correct each char within the 2D array according to the rules below. This process MUST be done by using a void function by sending the appropriate cell of the 2D array with a call-by-reference fashion. • If the row index is an even number, a char can only be a lowercase English value. • If the row index is an odd number, a char can only be ?, 7', or X'. • Any incorrect value MUST be changed into Finally, the checked and corrected 2D array will be printed out to the screen. NOTE: Checking the correctness of a char and correcting it (if necessary) MUST be done in the function with a…arrow_forwardThe index type of an array can be any data type. True or false?arrow_forward
- Assume an array is defined as int[] nums = {7, 15, 23, 5};. Which of the following would place the values in the array in descending numeric order? a. Array.Reverse(nums); b. Array.Reverse(nums); Array.Sort(nums); c. Array.Sort(nums); d. Array.Sort(nums); Array.Reverse(nums);arrow_forward2. Design a program using pseudocode with two parallel arrays: a String array named people and an String array named phoneNumbers. The program allows you to search for a person's name in the people array. If the name is found, it displays that person's phone number otherwise it should prompt the user the name was not found. The program should use the binary search algorithm.arrow_forwardWrite a program that will use a two-dimensional arrays named : Record[50][4]. The 1St column of the Record Array will store the Student Number, the grades Q1, Q2, PE and FE will be stored on the 2nd 3rd 4th and 5th column of the Record array, and the last column will store the average grade of 50 students. The data for Student Number, Q1, Q2, PE, and FE are to be entered from the keyboard while the average grade is to be computed using the equation : AVE = (Q1 + Q2 + 2 *PE + 2 * FE)/ 6 Print the content of Record Array in tabulated form with the header : Q2 STUDENT NO. Q1 PE FE AVE Make another print out of the Record Array, but this time the ave column of the Record array (that is, the las t column) must be sorted in descending order, with the same header as before. Create a function named PrintArray for printing its content both when the average grade is not yet sorted and when the average grade had been sorted.arrow_forward
- In C++ language Write a function that takes a 2 Demensional array and returns the position of the first row with an odd sum. Assume that the column size is fixed at 4. If no sum is odd, return -1.arrow_forwardQuestion 5 Using the concept of parallel arrays, create an application that stores information for 5 people. The application will ask the user for the following data for each person: • First Name • Last Name • Age • Date of Birth • Email Address The application will then output the data to the user Full explain this question and text typing work only thanksarrow_forwardUsing c++ write a program Program : Date Printer Write a program that reads a char array from the user containing a date in the form mm/dd/yyyy. It should print the date in the form March 12, 2014. For example Enter Date 5/14/2019 May 14, 2019 Validation Required: Month should be less than 13, day should be less than 31.arrow_forward
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,