Skip to content

This repository contains simple calculator programs written in Java.

Notifications You must be signed in to change notification settings

CyberSphinxxx/java-calculators-collection

Repository files navigation

Java Calculator Collection

This repository contains simple calculator programs written in Java. The calculators can perform basic arithmetic operations such as addition, subtraction, multiplication, and division. The current implementations use else if statements and switch cases to handle different arithmetic modes. More features and modes may be added in the future.

Features

  • Addition: Adds two numbers.
  • Subtraction: Subtracts the second number from the first number.
  • Multiplication: Multiplies two numbers.
  • Division: Divides the first number by the second number. Includes a check to prevent division by zero.

Programs

  1. Switch Calculator (switch_calculator.java): Uses a switch statement to handle the selection of arithmetic operations.

  2. Else If Calculator (Calculator_ElseIf.java): Uses else if statements to handle the selection of arithmetic operations.

  3. Ternary Calculator (TernaryCalculator.java): Uses a nested ternary operator to perform arithmetic operations in a compact, single-line expression.

  4. Function Calculator (Function_Calculator.java): Uses functions to handle the selection of arithmetic operations.

  5. Birthday Calculator (Whats_my_birthday.java): Calculates a person's age and the number of days until their next birthday based on their birth date and the current date.

How to Run

1. Clone the repository:

git clone https://github.com/your-username/java-calculator-collection.git

2. Navigate to the directory:

cd java-calculator-collection

3. Compile the Java files:

javac switch_calculator.java
javac Calculator_ElseIf.java
javac Calculator_Mini.java
javac Function_Calculator.java
javac Whats_my_birthday.java

4. Run the program:

For the Switch Calculator:

java switch_calculator

For the Else If Calculator:

java Calculator_ElseIf

For the Ternary Calculator

java Calculator_Mini

For the Function Calculator

java Function_Calculator

For the Birthday Calculator

java Whats_my_birthday

Contributing

Contributions are welcome! Please fork this repository and submit a pull request for any features or bug fixes you would like to add.

About

This repository contains simple calculator programs written in Java.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages