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

 

amjadm@miamioh.edu > calculate
prev  |  next  |  chance

Calculate the result based on the given expression. The instruction contains numbers followed by operators e.g. "1+2-4*2+1/2*2". Operators are + - * /. You need to parse the operations from left to right (rather than following standard order of operators in which some operators have priority over others).


calculate("9") → 9
calculate("1+2") → 3
calculate("2*2+3") → 7

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

public int calculate(String str) { }

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: 250 Post-solution available

Copyright Nick Parlante 2017 - privacy