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

 

cynthia.gallatin@pisd.edu lab5a > calculate
prev  |  next  |  chance

Given two numbers, a and b, and a character c which represents a mathematical operator (+, -, *, /), return the result of the mathematical expression. If the operator is not one of those listed, the calculate method should return -1.


calculate(1.5, 2.5, "-") → -1.0
calculate(2.2, 3.3, "+") → 5.5
calculate(4, 5, "?") → -1.0

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

public double calculate(double a, double b, char c){ }

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

Copyright Nick Parlante 2017 - privacy