Design and implement a service that simulates PHP loops. Each of the three loop variants should be encapsulated in an object. The service can be controlled via a parameter and execute three different simulations. The result is returned as JSON.
The input is an array consisting of the letters $characters = [A-Z].
-The For loop should store all even letters in an array.
-The Foreach loop simulation is to create a backward sorted array by For loop, i.e. [Z-A] .
-The While loop should write all characters into an array until the desired character is found.
Interface:
-GET Parameter String: loopType ( possible values: REVERSE, EVEN, UNTIL )
-GET parameter String: until (up to which character)
Output:
JSON Object: {loopName: <string>, result: <array> }
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images
- python exercise Given the following list: testlist2 = (23,50,12,80,10,90,34,78,4,19,53) Use testlist2 to create Numpy array of int16 and then display the array. Display the number of dimension of testnp. Display the shape of testnp. Display the number of bytes of testnp. Display the mean, sum, max, and min of testnp.arrow_forwardLanguage is C++ Lab10B: Binary Bubbles. Binary search is a very fast searching algorithm, however it requires a set of numbers to be sorted first. For this lab, create an array full of 11 integers which the user will generate. Like in the previous lab, assume that the values will be between -100 and +100. Then, using the sorting algorithm called BubbleSort, put the array in the correct order (from lowest to highest number). After this, please printthe array to the screen. Finally, search the array for the target value using Binary Search.The BinarySearch code will implement the algorithm described in the lecture slides. During this, you should print out a few key values which help Binary Search function. For example, this algorithm focuses on a low, mid, and high which correspond to the indices in the array the algorithm is currently considering and searching. Printing these values during the search process will help with debugging and fixing any issues. • BubbleSort sorts the array…arrow_forwardJAVASCRIPT Write the function divideArray() in script.js that has a single numbers parameter containing an array of integers. The function should divide numbers into two arrays, evenNums for even numbers and oddNums for odd numbers. Then the function should sort the two arrays and output the array values to the console.arrow_forward
- Sales.java contains a Java program that prompts for and reads in the sales for each of 5 salespeople in a company. Now modify the program as follows: Declare an array called sales to save the sales of 5 salespeople. Complete the header of the first for loop. This loop initializes the array. Complete the header of the second for loop. This loop computes the total of array elements. Add code to compute and print the average sale. Add another loop to print the id of each salesperson and the number of their sales. The salespeople are objecting to having an id of 0—no one wants that designation. Modify your program so that the IDs run from 1-5 instead of 0-4. // *************************************************************** // Sales.java // // Reads in and stores sales for each of 5 salespeople. Displays // sales entered by salesperson id and total sales for all salespeople. // // *************************************************************** import java.util.Scanner;…arrow_forwardYou have made a device that automatically measures both distance from a magnet and the magnetic field strength at that distance. The device sends the pair of data to your computer as a pair of real numbers. However, the device moves back and forth as it takes data, so neither the field measurement nor the distance measurement arrives in ascending or descending order. Write a code vector_sort that receives a two-dimensional array of numbers and sorts them based on either the first column or the second column (this must be an input to the function. The function must also either sort high-to-low or low-to-high, based on an input value. Write a main function that can read up to twenty pairs of data. The main function must also input whether you want to sort high-to-low or low-to high. It must also input whether you want to sort on magnetic field or distance. Finally the code must print the pair data as originally entered and then, after calling vector_sort, the ordered pair data. C Programarrow_forwardIn C programming: Write a function printAllCourses() which receives an array of course pointers and the array’s size, then prints all courses in the array by calling printCourseRow()arrow_forward
- Prompt: In Python language, write a function that applies the logistic sigmoid function to all elements of a NumPy array. Code: import numpy as np import math import matplotlib.pyplot as plt import pandas as pd def sigmoid(inputArray): modifiedArray = np.zeros(len(inputArray)) #YOUR CODE HERE: return(modifiedArray) def test(): inputs = np.arange(-100, 100, 0.5) outputs = sigmoid(inputs) plt.figure(1) plt.plot(inputs) plt.title('Input') plt.xlabel('Index') plt.ylabel('Value') plt.show() plt.figure(2) plt.plot(outputs,'Black') plt.title('Output') plt.xlabel('Index') plt.ylabel('Value') plt.show() test()arrow_forwardwrite in html and scriptarrow_forwardMain difference between an array and an ArrayList is that an ArrayList can store more data types an ArrayList can store more elements an ArrayList executes faster for retrieval and insertion an ArrayList takes care of the memory management automatically an ArrayList uses positions and an array uses indicesarrow_forward
- In javacode: Use ArrayList to create an array called myAL of type integer. --Fill the array with the values 5, 10, 15, 22, 33. --Print the array (use enhanced for loop). --Insert the value 25 between 10 and 15 and print the array.--Remove 2 elements on index 1 and 3 and then print the array.--Print if the array contains the value 123 or not.--Print the index of the element 22.--Print the size of the array.arrow_forwardin Pseudo code Create an array of size 10 and name RandArray populate the RandArray with random integer from 1 to 20. Every element in the RandArray must be changed as follows: If the value of the element is less than the array index, the element must be replaced with the index plus 10. If the value of the element is equal to the index, the element must be doubled. If the value of the element is greater than the index, the element must be replaced by the index squared. Print the original number and the changed number of the RandArray .arrow_forwardJAVA PROGRAM Chapter 7. PC #16. 2D Array Operations with Additional Requirements Write a program that creates an ArrayList of ArrayList of Doubles. The program should ask the user to enter the filename from the keyboard and validate the file for existence. Once the file is verified, the program should load the two-dimensional ArrayList with test data from the file. Be careful, as some of the files will contain rows with different number of elements. The program should work regardless whether the input data is perfectly rectangular or ragged. The program should have the following methods: • main. Main entry point for the program. • getRowSubtotal. This method should accept a two-dimensional ArrayList as its first argument and an integer as its second argument. The second argument should be the index of the row in the ArrayList. The method should return the subtotal of the values in the specified row. • getColSubtotal. This method should accept a two-dimensional ArrayList as its…arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY