Tuesday, October 27, 2015

Calculator Project

This is the first write-up of a software development exercise that I have used to help train developers. This post should be viewed as instructions for the instructor, more than a step-by-step guide for someone trying to learn.

In this project, the user will create a basic calculator application. The specific project steps are written to encourage the user to create a program that interacts from the command line. This is done to keep the focus of the project on Test Driven Development and good programming practices. After the main exercise is described, alternate variations are mentioned.

Phase 1

Create a command-line application that will prompt the user for two numbers, add the numbers together, and return the result.

The program flow should look like:

C:\> calculator.exe
Please enter the first number: 3
Please enter the second number: 4
The sum of 3+4 is 7.
C:\>

The main() method should call the Calculate() method on another object. The program should be able to accept and correctly add any integer less than half of the max integer available on the system.

Phase 2

Modify the existing calculator program to be able to perform subtraction. The user should enter two numbers just as with addition, but will be prompted to select an operation. All of the constraints from the first phase still apply.

Phase 3

Modify the existing calculator program to be able to perform multiplication and division. If the user enters a 0 as a divisor, the program should return a message indicating that division by 0 isn't possible.

Phase 4

Modify the existing calculator program to accept floating point values (decimal values) as well as integers.

Alternate Phase A

Using the calculation code developed in the first 4 phases, implement the entire application as a web site using MVC. The scope of this approach could be expanded to have the user interface mimic a calculator's interface with number and operation buttons.

Alternate Phase B

Using the calculation code developed in the first 4 phases, implement the entire application as a REST API, with a single page application (SPA) framework such as AngularJS as the user interface.

No comments:

Post a Comment