
Supplied code Document
/ Ch13_Ex11_MainProgram.cpp - given code below
// Ch13_Ex11_MainProgram.cpp - given code below // #include "stdafx.h" may uncomment this if Visual Studios requires
#include <iostream>
#include "myArray.h"
using namespace std;
int main()
{
// Creates list1 and list2
myArray list1(5);
myArray list2(5);
// Zeroing (initializing) first array
int i;
cout << "list1 : ";
for (i = 0; i < 5; i++)
cout << list1[i] << " ";
cout << endl;
// Prompt to enter five numbers into list1
cout << "Enter 5 integers: ";
for (i = 0; i < 5; i++)
cin >> list1[i];
cout << endl;
// show contents list1
cout << "After filling list1: ";
for (i = 0; i < 5; i++)
cout << list1[i] << " ";
cout << endl;
// Transfer five elements from list1 to list2, Print list2
list2 = list1;
cout << "list2 : ";
for (i = 0; i < 5; i++)
cout << list2[i] << " ";
cout << endl;
// Write three elements replacing first 3 of list1
cout << "Enter 3 elements: ";
for (i = 0; i < 3; i++)
cin >> list1[i];
cout << endl;
// Prints three elements of list1 just entered
cout << "First three elements of list1: " << endl;
for (i = 0; i < 3; i++)
cout << list1[i] << " ";
cout << endl;
// Create list3 for first time
// Induced Chaos by
// cramming -2 to 6 into array list3
myArray list3(-2, 6);
// Print 8 array location numbers from -2 through 5
// Should print zero eight times if memory is initialized
cout << "list3: ";
for (i = -2; i < 6; i++) cout << list3[i] << " ";
cout << endl;
list3[-2] = 7;
list3[4] = 8;
list3[0] = 54;
list3[2] = list3[4] + list3[-2];
// Print results to screen
cout << "list3: ";
for (i = -2; i < 6; i++)
cout << list3[i] << " ";
cout << endl;
system("pause");
return 0;
}
.** Do not change anything in the supplied code which is the Ch13_Ex11_MainProgram.cpp (except to add documentation and your name). Please use the file names listed below since your file will have the same components in the supplied code.
2. **Recall that in C++, there is no check on an array index out of bounds.** However, during program execution, an array index out of bounds can cause serious problems. Also, in C++, the array index starts at 0.
3. **Design and implement the class `myArray`** that solves the array index out of bounds problem and also allows the user to begin the array index starting at any integer, positive or negative.
- Every object of type `myArray` is an array of type `int`. During execution, when accessing an array component, if the index is out of bounds, the program must terminate with an appropriate error message. Consider the following statements:
```cpp
myArray list(5);
//Line 1 myArray
myList(2, 13);
//Line 2
myArray yourList(-5, 9);
//Line 3
```
The statement in Line 1 declares list to be an array of 5 components, the component type is `int`, and the components are: `list[0]`, `list[1]`, ..., `list[4]`. The statement in Line 2 declares `myList` to be an array](https://content.bartleby.com/qna-images/question/69463cef-e943-4ccb-87fa-6ffaeb77fa1b/a70ab880-8af1-452b-8709-1f67dae00897/m11ly0t_thumbnail.png)

Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images

Could you please look at step 3, for some reasons I am getting errors?
![myArray.cpp
++Array Out_of_Bounds Instructions
#pragma once
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
myArray.h* X Ch13_Ex11_MainProgram.cpp
class myArray
{
public:
myArray (int indexs, int indexE);
myArray (int arrayLength);
int& operator[] (const int index);
private:
8:
int* list;
int length;
int indexStart;
int indexEnd;
};
Bint& myArray::operator[](int index) //overloading array index
{
if (index >= indexStart && index <= indexEnd) //check to see if its within bounds
{
}
else
{
}
int& indexLoc = *(list + index); //set memeory location to store actual value of the list index.
return indexLoc;
cout << "Index is out of range.\n";
exit(0);
→↓↓ myArray
}
✓ No issues found
100%
Error List
Entire Solution
Description
Code
XC2065
X C2065
'cout': undeclared identifier
'cout': undeclared identifier
X C3861 'exit': identifier not found
9
X 3 Errors A 0 Warnings ✪ 0 Messages Build+ IntelliSense
operator[](int index)
Project
Array Out_of_Bounds Instructions
Array Out of Bounds Instructions
Array Out_of_Bounds Instructions
File
myArray.h
myArray.h
myArray.h
Ln: 27
Ch: 36
Col: 42
Search Error List
Line
27
27
28](https://content.bartleby.com/qna-images/question/69463cef-e943-4ccb-87fa-6ffaeb77fa1b/8867ed70-23e2-4f57-80ae-ce5e45a38f48/m4k5qfs_thumbnail.png)
Could you please look at step 3, for some reasons I am getting errors?
![myArray.cpp
++Array Out_of_Bounds Instructions
#pragma once
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
myArray.h* X Ch13_Ex11_MainProgram.cpp
class myArray
{
public:
myArray (int indexs, int indexE);
myArray (int arrayLength);
int& operator[] (const int index);
private:
8:
int* list;
int length;
int indexStart;
int indexEnd;
};
Bint& myArray::operator[](int index) //overloading array index
{
if (index >= indexStart && index <= indexEnd) //check to see if its within bounds
{
}
else
{
}
int& indexLoc = *(list + index); //set memeory location to store actual value of the list index.
return indexLoc;
cout << "Index is out of range.\n";
exit(0);
→↓↓ myArray
}
✓ No issues found
100%
Error List
Entire Solution
Description
Code
XC2065
X C2065
'cout': undeclared identifier
'cout': undeclared identifier
X C3861 'exit': identifier not found
9
X 3 Errors A 0 Warnings ✪ 0 Messages Build+ IntelliSense
operator[](int index)
Project
Array Out_of_Bounds Instructions
Array Out of Bounds Instructions
Array Out_of_Bounds Instructions
File
myArray.h
myArray.h
myArray.h
Ln: 27
Ch: 36
Col: 42
Search Error List
Line
27
27
28](https://content.bartleby.com/qna-images/question/69463cef-e943-4ccb-87fa-6ffaeb77fa1b/8867ed70-23e2-4f57-80ae-ce5e45a38f48/m4k5qfs_thumbnail.png)
- Python question please include all steps and screenshot of code. Also please provide a docstring, and comments throughout the code, and test the given examples below. Thanks. Write a function called honorRoll(). Its only input parameter is a list that contains listsconsisting of a name followed by a series of grades (integers). All grades will be in therange 0-100. All students will have at least one grade, but not all students will have thesame number of grades. Your function should return a list of students whose averagegrade is above 92.0.>>> honorRoll([['Alice', 95, 92, 98], ['Carlos', 85, 87, 95, 91], ['Betty', 81, 74, 89]])['Alice']>>> honorRoll([['Alice', 92, 92, 92], ['Bob', 81, 46]])[]arrow_forwardAfter a tuple is created, its items can be changed. True False A tuple's items can be access by square brackets, similar to lists. True Falsearrow_forwardvrite a each eler the original assigns the element with 0. Ex: lowerScores = {5, 0, 2, -3} becomes {4, 0, 1, 0}. 406554.2871636.qx3zqy7 1 #include 2 #include 3 using namespace std; 4 5 int main() { 6 7 9 10 11 12 13 14 15 16 17 Run const int SCORES_SIZE = 4; vector lowerScores (SCORES_SIZE); unsigned int i; for (i 0; i > lowerScores.at(i); } /* Your solution goes here */ for (i = 0; i < lowerScores.size(); ++i) { cout << lowerScores.at (i) << " "; nent was greater than 0, and oth wise.arrow_forward
- POEM List[POEM_LINE] PRONUNCIATION_DICT Dict[str, PHONEMES] Do not add statements that call print, input, or open, or use an import statement. Do not use any break or continue statements.arrow_forwardpython help, please show all steps and include comments Write a function largerLst() that takes a list of numbers (i.e., int or float values) as a parameter and returns a new list constructed out of it. The list returned has all the values in the parameter list that are larger than the element immediately to their right, that is, larger than their right neighbor. If the parameter list is empty or there are no values larger than their right neighbor, then the function returns an empty list. Note that the last element in the list will never be included in the list returned since it does not have a right neighbor. The function should not change the parameter list in any way. Note that a correct solution to this problem must use an indexed loop That is, one that makes a call to the range() function to generate indices into the list which are used to solve the problem (Review lecture notes 8-1). A solution that does not use an indexed loop will not be accepted. Note in particular that you…arrow_forwardLottery number generator: Write a program that generates aseven-digit lottery number. The program should have a loopto generate seven random numbers, each in the range 0through 9 and assign each number to a list element.2. Write another loop to display the contents of the list.3. Tip: You will need to create/initialize your list before you canassign numbers to it.4. Use program 7-1 sales_list as an example. You will start witha seven-digit lottery number that contains all zeros. Then inyour loop, you will assign a random number instead ofgetting the data from the user.Turn in your program to the practice assignment link in coursecontent.arrow_forward
- Cassignm222 Assignment 2 features designing a program using pseudocode and then completing the program in Python using a list. M4Lab2 asks you to write a Drawing app in Python and Pygame using a list for the colors. Each lab asks you to write pseudocode that plans the program's logic before you write the program in Python and to turn in three things: 1) the pseudocode, 2) a screenshot of the output, and 3) the Python program. # Step 1: Define a colors list to describe 3 colors.# Hint, use their RGB number values Step 2: define a radius variable for your pen at 5, 10 or 15# Test them to see which radius you prefer and use it # Step 3: write the elif for pressing button 2, similar to button 1 # Step 4: write the statement for button 2's color # Step 5: write the else statement for button 3 # Step 6: choose a color from the list??arrow_forward6. list_n_perfect_squares This function takes a positive integer, n, and returns a list containing n perfect square numbers, starting with 1 and counting up to n2 Use a list comprehension and a range! Sample runs should look like: >>> list_n_perfect_squares ( 6) [1, 4, 9, 16, 25, 36] >>> list_n_perfect_squares (1) [1] >>> list_n_perfect_squares (20) [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]arrow_forward11111 2) Name: 2. The following procedure is intended to return the number of times the value val appears in the list myList. The procedure does not work as intended. Line 01: PROCEDURE countNumOccurences (myList, val) Line 02: { Line 03: FOR EACH item IN myList Line 04: } BL Line 05: count 0 Line 06: IF(item = val) %3D Line 07: Line 08: count count + 1 :60 Line 10: { { RETURN(count) Line 11: Line 12: } Which of the following changes can be made so that the procedure will work as intended? a. Moving the statement in line 5 so that it appears between lines 2 and 3 C. Changing line 6 to IF(item = count) b. Changing line 6 to IF(myList[item] = val) d. Moving the statement in line 11 so that it appears between lines 9 and 10arrow_forward
- Python Programmingarrow_forward5. Charge Account Validation If you have downloaded the source code from the Computer Science Portal you will find a file named charge_accounts.txt in the Chapter 07 folder. This file has a list of a com- pany's valid charge account numbers. Each account number is a seven-digit number, such as 5658845. Programming Exercises 403 program Write a program that reads the contents of the file into a list. The program should then ask the user to enter a charge account number. The program should determine whether the number is valid by searching for it in the list. If the number is in the list, the should display a message indicating the number is valid. If the number is not in the list, the program should display a message indicating the number is invalid. (You can access thearrow_forward#include <iostream>#include <iomanip>#include <string>using namespace std;struct menuItemType{string menuItem;double menuPrice;};void getData(menuItemType menuList[]);void showMenu(menuItemType menuList[] , int n);void printCheck(menuItemType menuList[], int menu_order[], int n);int main(){const int item = 8;menuItemType menuList[item];int menu_order[item] ={0};int choice =0;int count =0;bool order = true;getData(menuList);showMenu(menuList,item);while(order){cout<<"Enter the choice for the order or press 0 to exit"<<endl;cin>>choice;if(choice>0 && choice<=item){menu_order[choice-1]+=1;}else{order=false;}}printCheck(menuList,menu_order,item);return 0;}void getData(menuItemType menuList[]){menuItemType plainEgg;menuItemType baconEgg;menuItemType muffin;menuItemType frenchToast;menuItemType fruitBasket;menuItemType cereal;menuItemType coffee;menuItemType tea;plainEgg.menuItem = "Plain Egg";plainEgg.menuPrice = 1.45;baconEgg.menuItem =…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





