about | help | code help+videos | done | prefs |
Write a method that calculates the result of a series of operations performed on an array of integers. The operations to be performed are contained in the string 'ops'. Each operation is performed in the order they are listed in 'ops'. The order of operations is NOT followed. Simply perform the calculations in order. The only possible operators are +, -, *, and /. Note that the division operation / will use integer division, so 3/2 results in 1. For example, {8,2,3} with the string "+*" will result in 30 since 8+3 is 10 and then 10*3 is 30. Note that the string 'ops' will have a number of operations equal or greater to one less than the number of integers in the array. So if the array has 7 numbers in it, 'ops' will have at least 6 operations. If the array of integers only has one number in it, simply return that number. If the array is empty just return 0. Look at the test data for examples. dec18_2015_SLHL_parseOperations([6, 2, 3, 5], "*+*") → 75 dec18_2015_SLHL_parseOperations([5], "") → 5 dec18_2015_SLHL_parseOperations([], "+-+") → 0 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 330
Copyright Nick Parlante 2017 - privacy