Concept explainers
Insert const before any of the following array parameters that can be changed to constant array Parameters:
void output (double a[], int size);
//Precondition: a[0] through a[size – 1] have values.
//Postcondition: a[0] through a[size – 1] have been
//written out.
void dropOdd(int a[ ], int size);
//Precondition: a[0] through a[size – 1] have values.
//Postcondition: All odd numbers in a[0] through
//a[size – 1] have been changed to 0.
Want to see the full answer?
Check out a sample textbook solutionChapter 7 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
Electric Circuits. (11th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Mechanics of Materials (10th Edition)
Starting Out With Visual Basic (8th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
Starting Out with Python (4th Edition)
- Alert dont submit AI generated answer.arrow_forward//convert array of numbers from farenheit to celcius// example:// argument: [23, 32, 41, 50, 59]// return: [-5, 0, 5, 10, 15]// hint: use Array.mapfunction toCelcius(array){ } //write a function that takes an input array and returns an array of booleans (>=75) or fail (<75)// example:// argument: [20, 30, 50, 80, 90, 100]// return: [false, false, false, true, true, true]// hint: use Array.mapfunction passOrFail(array){ }arrow_forwardRewrite the client program to use the Baby class that you have done using ArrayList. You should also have the following function in this new client program: a) Enter details for each baby (name and age) and thus populate the Baby ArrayList b) Calculate and display the average age of all babies in the ArrayList c) Ask the user to enter the name of a baby, and then remove it from the ArrayList d) Allow the user to add new baby information in the ArrayList e) Output the details of each baby from the ArrayList (name and age) Compare this client program using the ArrayList with the client program you have done using array, comment on the differences between the two. Modify your client program in the last question, by adding a sort function such that when that option is selected, it sorts the ArrayList using the baby names in alphabetical order and output the details in the sorted ArrayList to a CSV (sortedbabylist.csv) file. public class Baby { private String name; private int age;…arrow_forward
- JAVA ARRAY MANIPULATION QUESTION: make a method called manipulator that takes a double array as parameter and modifies it. The method will modify the array then print the array. The method must modify the existing array, it CAN NOT create a different array as the solution. The manipulator method will be a void method. Remember: To get an average of 2 digits you add them together then divide by 2. Average of x and y = (x+y)/2 Modifications the method will do: For every 2 consecutive elements in the array, both the elements are replaced by their average. If the number of elements in an array is odd don't modify the last number of the array. Basically, you find the average of 2 consecutive elements then replace both of the elements with that value. Examples: Array = {2.0,3.0} will be changed to {2.5,2.5} when passed to the manipulator method Array = {2.0,3.0,45} will be changed to {2.5,2.5,45} when passed to the manipulator method Array = {2.0,3.0,45,55} will be changed to…arrow_forwardRotate Right k cells (use python) Consider an array named source. Write a method/function named rotateRight( source, k) that rotates all the elements of the source array to the right by 'k' positions. You must execute the method by passing an array and number of cells to be shifted. After calling the method, print the array to show whether the elements have been shifted properly. Example: source=[10,20,30,40,50,60] rotateRight(source,3) After calling rotateRight(source,3), printing the array should give the output as: [ 40, 50, 60, 10, 20, 30]arrow_forwardDescription: Write a method that return the average of an array with the following header: public static double average(double[] array); In the main method, 5 double numbers are required to be entered. Input Example: 1.2 1.2 1.3 1.3 1.35 Output Example: The average value is 1.27arrow_forward
- Write method body of following methods: InsertNum(int num) // The function takes a number from user as input and it is intelligent enough to place the number at desired index of an array. For example if array has values from 1,3,5,7 and user entered 6 so the function will place 6 after 5 and before 7. (Use While Loop) InsertNum(int num,int position) // This function takes number and position from user and then place the number at desired position of array. Remember to ask from user if there is already a number at that position. (Code in C++)arrow_forwardan int variable k, an int array currentMembers that has been declared and initialized, an int variable nMembers that contains the number of elements in the array, an int variable memberID that has been initialized, and a bool variable isAMember, Write code that assigns true to isAMember if the value of memberID can be found in currentMembers, and that assigns false to isAMemberotherwise. Use only k, currentMembers, nMembers, and isAMember.arrow_forwardInput: The first line will consists of one integer T denoting the number of test cases. For each test case: 1) The first line consists of two integers N and K, N being the number of elements in the array and K denotes the number of steps of rotation. 2) The next line consists of N space separated integers, denoting the elements of the array A. Output: Print the required array. Constraints:arrow_forward
- the parameter passing mechanism for an array is call by value or call by reference?arrow_forwardint main() { int inStock[10][4]; int alpha[20]; int beta[20]; int gamma[4] = {11, 13, 15, 17}; int delta[10] = {3, 5, 2, 6, 10, 9, 7, 11,1, 8};. . .} a. Write the definition of the function setZero that initializes any onedimensional array of type int to 0. b. Write the definition of the function inputArray that prompts the user to input 20 numbers and stores the numbers into alpha. c. Write the definition of the function doubleArray that initializes the elements of beta to two times the corresponding elements in alpha. Make sure that you prevent the function from modifying the elements of alpha. d. Write the definition of the function copyGamma that sets the elements of the first row of inStock to gamma and the remaining rows of inStock to three times the previous row of inStock. Make sure that you prevent the function from modifying the elements of gamma. e. Write the definition of the function copyAlphaBeta that stores alpha into the first five rows of inStock and beta into the…arrow_forwardFor the array ADT, the operations associated with the type array are: insert a value in the array, delete a value from the array, and test whether a value is in the array or not. 1.true 2.falsearrow_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