Mini Project: Console Calculator
Build a small calculator function using switch without console input. Handle +, -, *, /, validate division by zero, and design clean tests.
Project Brief
Goal: Implement a reusable calculator method without console input. The method takes two numbers and an operator, returns the result, and validates division by zero.
API Design
API
static double calc(double a, double b, char op)- op:
'+','-','*'/'x','/' - Invalid operator: throw
IllegalArgumentException - No user input inside the method
All lessons in this course
- Comparison & Logical Operators Deep Dive
- Switch Statements
- Mini Project: Console Calculator