For any element in keysList with a value greater than 100, print the corresponding value in itemsList, followed by a space. Ex: If keysList = {42, 105, 101, 100} and itemsList = {10, 20, 30, 40}, print: 20 30
Since keysList.at(1) and keysList.at(2) have values greater than 100, the value of itemsList.at(1) and itemsList.at(2) are printed.
#include <iostream>
#include <
using namespace std;
int main() {
const int SIZE_LIST = 4;
vector<int> keysList(SIZE_LIST);
vector<int> itemsList(SIZE_LIST);
unsigned int i;
for (i = 0; i < keysList.size(); ++i) {
cin >> keysList.at(i);
}
for (i = 0; i < itemsList.size(); ++i) {
cin >> itemsList.at(i);
}
/* Your solution goes here */
cout << endl;
return 0;
}
Please help me with this problem using c++.
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images
- Using phyton code: First, ask the user the following three questions and store the answers in a nested list. What is your name? What is your quest? What is your favorite color? Store at least 6 sets of responses. Example nested list: [ ['Sir Robin' , 'to find the Holy Grail' , 'red'] , ['Matt' , 'to travel the world' , 'blue'], etc...] Second, sort the list alphabetically by color and print out the results: Sample output:arrow_forwardCode NOT working. What to do? Here is code: appleList = [["Apple",52,14,0,0],["McIntosh red",80,18,0,0.5],["Gala (Apple)",52,11.4,0.2,0.3],["Fuji Apple",52,11.4,0.2,0.3],["Honey Crisp Apples",90,21,0,0],["Granny Smith Apples",52,11.4,0.2,0.3],["Red Delicious Apples",80,17,0,0],["Braeburn Apples",71.7,16,0.5,0.1],["Golden Delicious Apples",130,29,1,0],["Jonagold",130.7,34,1,0],["Cripps Pink Apple",80,18,0,0],["Empire Apples",80,17,0,0],["Produce Cortland Apples",70,6,1,5],["Jazz Apples",53.8,12,0.6,0.5],["Cameo Apples", 80,22,0,0]["Winesap Apples",80,22,0,0],["Rome Apples",80,22,0,0],["Ambrosia Apples",90,17,0.4,0],] print(":Type of Apple : Calories : Carbs (in GRAMS) : Protein (in GRAMS) : Fat (in GRAMS) :") for item in appleList:print(":",item[0]," "*(9-len(item[0])),":",item[1]," "*(13-len(item[1])),":",item[2]," "*(4-len(str(item[2]))),":")arrow_forwardWrite a for loop to print all elements in courseGrades, following each element with a space (including the last). Print forwards, then backwards. End each loop with a newline. Ex: If courseGrades = {7, 9, 11, 10), print: 7 9 11 10 10 11 9 7 Hint: Use two for loops. Second loop starts with i = NUM_VALS - 1. Note: These activities may test code with different test values. This activity will perform two tests, both with a 4-element array (int courseGrades[4]). Also note: If the submitted code tries to access an invalid array element, such as courseGrades[9] for a 4-element array, the test may generate strange results. Or the test may crash and report "Program end never reached", in which case the system doesn't print the test case that caused the reported message. 1 #include HNm in 10 m DO G 2 3 int main(void) { 4 5 6 const int NUM_VALS = 4; int courseGrades [NUM_VALS]; int i; 7 8 for (i = 0; i < NUM_VALS; ++i) { scanf("%d", &(courseGrades[i])); 9 } 10 11 12 13 14 15 } /*Your solution…arrow_forward
- Which of the following correctly stores the third element in myArray. int [] myArray = {1,2,3,4,5}; O int num = myArray(2); O int num = myArray(3); O int num = myArray[2]; O int num = myArray[3];arrow_forwardWrite a for loop to print all elements in courseGrades, following each element with a space (including the last). Print forwards, then backwards. End each loop with a newline. Ex: If courseGrades = {7, 9, 11, 10}, print:7 9 11 10 10 11 9 7 Hint: Use two for loops. Second loop starts with i = NUM_VALS - 1. Note: These activities may test code with different test values. This activity will perform two tests, both with a 4-element array (int courseGrades[4]). Also note: If the submitted code tries to access an invalid array element, such as courseGrades[9] for a 4-element array, the test may generate strange results. Or the test may crash and report "Program end never reached", in which case the system doesn't print the test case that caused the reported message. #include <iostream>using namespace std; int main() { const int NUM_VALS = 4; int courseGrades[NUM_VALS]; int i; for (i = 0; i < NUM_VALS; ++i) { cin >> courseGrades[i]; } /* Your solution goes…arrow_forwardThis class will allow a user to enter 5 scores into an array. It will then rearrange the datain descending order and calculate the mean for the data set.Attributes: data[]— the array which will contain the scores mean — the arithmetic average of the scoresMethods: Average — the constructor. It will allocate memory for the array. Use a forloop to repeatedly display a prompt for the user which should indicate that userCopyright © 2019 Pearson Education, Inc., Hoboken NJshould enter score number 1, score number 2, etc. Note: The computer startscounting with 0, but people start counting with 1, and your prompt should accountfor this. For example, when the user enters score number 1, it will be stored inindexed variable 0. The constructor will then call the selectionSort and thecalculateMean methods. calculateMean — this is a method that uses a for loop to access each scorein the array and add it to a running total. The total divided by the number ofscores (use the length of the array),…arrow_forward
- FIX THIS CODE Using python Application CODE: import csv playersList = [] with open('Players.csv') as f: rows = csv.DictReader(f) for r in rows: playersList.append(r) teamsList = [] with open('Teams.csv') as f: rows = csv.DictReader(f) for r in rows: teamsList.append(r) plays=len(playersList) for i in range(plays): if playersList[i]['team']=='Argentina' and int(playerlist[i]['minutes played'])<200 and int(playersList[i] ['shots'])>20: print(playersList[i]['last name']) c0=0 c1=0 c2=0 for i in range(len(teamsList)): if int(teamsList[i]['redCards'])==0: c0=c0+1 if int(teamsList[i]['redCards'])==1: c1=c1+1 if int(teamsList[i]['redCards'])==2: c2=c2+1 print("Number of teams with zero redcards:",c0) print("Number of teams with zero redcards:",c1) print("Number of teams with zero redcards:",c2) ratio=0 for i in range(len(teamsList)): if int(teamsList[i]['games']>3) and if int(teamsList[i]['goalsFor'])/int(teamsList[i]['goalsAgainst'])<ratio:…arrow_forward# TODO y_values = display(y_values) todo_check([ (y_values.shape == (120,),'y_values does not have the correct shape of (120,)'), (np.all(np.isclose(y_values,…arrow_forward21. Which properties will extend a grid item so that it covers multiple rows and columns, specifically the area from row gridlines 3 to 5 and from column gridlines 1 to 3? Group of answer choices a. grid-row: 3/5; grid-column: 1/3; b. grid-row: 2/4; grid-column: 4; c. grid-column-start: 3; grid-column-end: 5; d. grid-column-start-end: 1/3; grid-row-start-end: 3/5;arrow_forward
- The intNum array is declared as follows: Dim intNum(,) As Integer = {{6, 12, 9, 5, 2}, {35, 60, 17, 8, 10}}. Which of the following If clauses determines whether the intRow and intCol variables contain valid row and column subscripts, respectively, for the array? a. If intNum(intRow, intCol) >= 0 AndAlso intNum(intRow, intCol) < 5 Then b. If intNum(intRow, intCol) >= 0 AndAlso intNum(intRow, intCol) <= 5 Then c. If intRow >= 0 AndAlso intRow < 3 AndAlso intCol >= 0 AndAlso intCol < 6 Then d. If intRow >= 0 AndAlso intRow < 2 AndAlso intCol >= 0 AndAlso intCol < 5 Thenarrow_forward•is Valid Phone Number(): ReturnsTrue if the provided phone number (represented as a string) is cor-rectly formatted, otherwiseFalse. To be considered correctly formatted, phone numbers must bewritten as###-###-####, where#is a digit between 0 and 9 .•validatePhoneBook(): A phone book is a list where each entry is a phone book record (represented asa dictionary; see below for more details). This function checks each phone book record in the phonebook for correctly formatted phone numbers.A phone book record is a dictionary which initially has two keys: the key"name"mapped to thecontact’s name (string) and the key"phone number"mapped to that contact’s phone number (alsoa string).validatePhoneBook()adds a new key"valid"to the record with the valueTrueif the phonenumber is formatted correctly, otherwiseFalse. 1. Write white-box and black-box tests for the function is ValidPhoneNumber(). You should do this with-out Python, either on paper, or in a simple document. Don’t worry about…arrow_forwardCreate an array of three string values that the fullName variable will use as a point of reference. Make an initialization list for the array using string values for the first, middle, and last names.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