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

 

test2023_11_16_APP1SLHL_mathProblem


Write a method that returns a string that represents the calculation and result of performing either addition or subtraction on 'x' and 'y'. The only acceptable operations are "+" or "-". Any other value for 'operation' results in the string "error" being returned. Look at the test data for examples.


test2023_11_16_APP1SLHL_mathProblem(-80, 30, "+") → "-80+30=-50"
test2023_11_16_APP1SLHL_mathProblem(5, 5, "-") → "5-5=0"
test2023_11_16_APP1SLHL_mathProblem(71, 22, "this does not work") → "error"

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

public String test2023_11_16_APP1SLHL_mathProblem(int x, int y, String operation) { }

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

Copyright Nick Parlante 2017 - privacy