Coder Social home page Coder Social logo

calculator's Introduction

Calculator

Simple console application created for educational purposes.

Created with:

  • Visual Studio Community 2017

Used programming languages:

  • C#

Functionalities:

This program sums, subtracts, multiplies and divides two decimal numbers.

How it works?

  1. Choose from 1 to sum, 2 to subtract, 3 to multiply or 4 to divide your numbers. Type your choice and confirm by pressing "enter".
  2. Type in your first number and press "enter".
  3. Type in your second number and press "enter".
  4. The result of your mathematical operation will be displayed in Console.
  5. To calculate once again, press "enter".
  6. To close application type "0" and press "enter". If you type in wrong number or character, console will display information about it and will go back to main menu.

calculator's People

Contributors

javorske avatar

Watchers

Kamil Jaworski avatar  avatar

calculator's Issues

Improve handling of incorrect user input

Current solution does not handle ArgumentNullException and OverflowException (in fact, it handles only FormatException).
image

It's better to use int.TryParse, which allows to have more control over the user input. try-catch is not necessary - it makes the code less comprehensible.

Multiplication

Add multiplication to menu and method that multiplies two numbers

Strategy pattern not fully implemented in Program.cs

Interface and concrete classes have been created, but Program.cs does not utilize polymorphism:
image

No need to create separate variable for each case in switch - just declare variable of IMathOperation type before switch and call MathOperation() after switch.
Use switch only to assign a concrete implementation of IMathOperation to the variable.

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.