Git Product home page Git Product logo

simplecalculatorjuniper's Introduction

Simple Interactive Calculator

Goal

Create a Console based Calculator in C#.

Rules

  • You can work in pairs if you like, but it's not required.
  • Everyone forks this repo (then clone your fork).
  • Everyone has until the beginning of class on Saturday to complete this task (this includes pushing to github)
  • There should be Unit Tests on all classes and methods you create.
  • Your solution should have at least 2 total projects. Unit Tests should be in it's own project.
  • This is an OOP focused class. Therefore, there will be classes. No implementations should be done within the Program class and Main method.
  • If a user submits an incomplete command or expression, the calculator should not attempt to evaluate it and print out a useful message.

How it should work

Starting your console application should create a prompt that looks like:

[x]> 

where x is the number of executed commands/expressions during the user's current session. Call this your "counter".

On startup, your initial prompt should always look like:

[0]>

The user will enter simple mathematical expressions or commands. The user pressing [Enter] will have the calculator print out the correct answer on the following line (prefixed with an =). After the answer is printed, the user should return to the original prompt.

For example, below the user entered 2+1, then pressed [Enter]. The calculator printed out the answer 3 and reprinted the prompt, waiting for input from the user.

[0]> 2+1
   = 3
[1]>

Further use of this session will again increment the counter part of the prompt:

[1]> 1-10
   = -9
[2]>

Finally, typing exit or quit should exit the program while printing a message:

[2]> exit
Bye!!

Features

Math Operations

Your calculator should following operations

  1. addition (integer)
  2. subtraction (integer)
  3. integer division (integer)
  4. modulus (integer)
  5. multiplication (integer)

Calculator Commands

In addition to math expressions, your calculator should accept the following commands:

  • quit and exit - exits the program
  • last - prints the last printed answer
  • lastq - prints the last entered command or expression

Constants

For the chosen few, you get the implement the concept of 'constants' in the caluculator. See below for how it should work:

[0]> x = 3
   = saved 'x' as '3'
[1]> x
   = 3
[2]> 1 + x
   = 4
[3]> x = 4
   = Error!

Constants Specifications

  1. Any lowercase letter of the alphabet can be a constant.
  2. Calculator should be case insensitive. A is considered the same as a.
  3. Constants can only be defined once per session.
  4. Defined constants can be used in math expressions
  5. Undefined constants can not be used and if used should print a helful message.

simplecalculatorjuniper's People

Contributors

lynnsamuelson avatar jcockhren avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.