id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > parseOperationsSLAP_Dec2011
prev  |  next  |  chance

Write a method that has a string and an array of integers as input parameters. The length of the string in characters will be the same as the length of the array of integers. The string will start with either "+" or "-" and will only contain the symbols + - * / in any order. Note that the "/" symbol will represent integer division, ignoring the remainder. Your method returns the result of performing the various operations in the string on the numbers in the array. For example: parseOperationsSLAP_Dec2011("++*-",{8,12,3,5}) returns 55 after performing the calculations: 0+8=8, 8+12=20, 20*3=60, 60-5=55. Note that the operations are performed in the order given in the string based on the running total and that the order of operations is disregarded entirely. Also note that the first operation will be either adding or subtracting from zero. Any integer may be used with any operation EXCEPT there will be no division by zero attempted. Also note that the running total will always be a valid integer value so you don't have to worry about overflow or anything scary like that. Boo. Oh by the way... The string will never have a division symbol followed immediately by another division symbol. That would be interpreted as an escape character so I just won't do it in any of the test data. Hurray!!! And one more thing... The string will have at least one character in it!


parseOperationsSLAP_Dec2011("++/", [7, 11, 2]) → 9
parseOperationsSLAP_Dec2011("+", [5]) → 5
parseOperationsSLAP_Dec2011("-", [1000]) → -1000

...Save, Compile, Run (ctrl-enter)

public int parseOperationsSLAP_Dec2011(String ops, int[] nums) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 280

Copyright Nick Parlante 2017 - privacy