- Saved searches
- Use saved searches to filter your results more quickly
- scientific-calculator
- Here are 37 public repositories matching this topic.
- anubhavshrimal / CalculatorApp
- cavallium / WarpPI
- woheller69 / Arity
- alimranahmed / CI-Calculator
- palmcalc2019 / PalmCalc
- royayon / AynCalculator
- ruhulaminparvez / Scientific-Calculator
- OpeyemiOluwa12 / ScientificCalculator
- MinhasKamal / UltimateCalculator
- GNiruthian / scientific-calculator
- mamutalib / Scientific_Calculator
- hassanzadehmahdi / Scientific-Calculator
- Shruthi-Sivagnanam / Calculator
- Yassine-Lafryhi / ScientificCalculator
- ljcharles / FreshCalculator
- RupamMukherjee492 / Scientific_Calculator_Android_App
- iam-debanjan007 / Terminal-Scientific-Calculator
- abhijeet080808 / FlexiCalculator
- kshitiz1007 / Calculator
- aratheunseen / java-scientific-calculator-gui
- Improve this page
- Add this topic to your repo
- advanced calculator. implementing multiple operands
- 1 Answer 1
- Saved searches
- Use saved searches to filter your results more quickly
- Mayonaka88/java-advanced-calculator
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
- Saved searches
- Use saved searches to filter your results more quickly
- aepikalov/JavaPatterns_2_1_Structural
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
scientific-calculator
Here are 37 public repositories matching this topic.
anubhavshrimal / CalculatorApp
scientific calculator basic calculator and unit converter android app
cavallium / WarpPI
WarpPI Calculator, Step-by-step algebra calculator for Raspberry Pi. (abandoned project)
woheller69 / Arity
Scientific calculator with complex numbers and graphing of user-defined functions.
alimranahmed / CI-Calculator
CI-Calculator, A scientific calculator, built using JAVA. Front-end has been designed by java swing API.
palmcalc2019 / PalmCalc
Multi-function Scientific Calculator for Android
royayon / AynCalculator
Android App Scientific Calculator and Converters.
ruhulaminparvez / Scientific-Calculator
A Scientific Calculator Built Using Android Studio ☺ 🤞
OpeyemiOluwa12 / ScientificCalculator
Scientific Calculator developed in javafx
MinhasKamal / UltimateCalculator
Basic Scientific Calculator (math-calculation-equation-unit-converter-unitconverter-advanced-mathematics-math-number)
GNiruthian / scientific-calculator
mamutalib / Scientific_Calculator
Currency Converter in Java
hassanzadehmahdi / Scientific-Calculator
A scientific calculator program that gets infix expressions from input, converts them to postfix and prefix notation, and shows the result by evaluating the postfix expression.
Shruthi-Sivagnanam / Calculator
Scientific Calculator — designed in java
Yassine-Lafryhi / ScientificCalculator
An Android application of a basic scientific calculator
ljcharles / FreshCalculator
Calculatrice Android Studio
RupamMukherjee492 / Scientific_Calculator_Android_App
I developed a Scientific Calculator Android app, which is a Scientific Calculator Android app is a mobile application designed to provide users with advanced mathematical functions and calculations. The app is designed to help users perform complex calculations quickly and easily.
iam-debanjan007 / Terminal-Scientific-Calculator
Terminal based Scientific calculator in java
abhijeet080808 / FlexiCalculator
Flexible Android Calculator
kshitiz1007 / Calculator
It is a calculator app build on android platform
aratheunseen / java-scientific-calculator-gui
This is a basic scientific calculator created in Java and Java Swing.
Improve this page
Add a description, image, and links to the scientific-calculator topic page so that developers can more easily learn about it.
Add this topic to your repo
To associate your repository with the scientific-calculator topic, visit your repo’s landing page and select «manage topics.»
advanced calculator. implementing multiple operands
Need a way to finish my ‘advanced’ calculator. i’ve been brainstorming with loops but im confusing myself. any ideas on how to implement the operands to the numbers without just nesting a bunch of if statements and hard coding through all of that.
public static void main(String[] args) < Scanner scan = new Scanner(System.in); System.out.println("welcome to your personal calculator. is your problem simple or advanced(multiple calculations)\n" + "Type 1 for simple or 2 for advanced"); int choice = scan.nextInt(); if(choice == 1)< System.out.println("Simple equation"); System.out.println("Enter the first number"); int firstnum = scan.nextInt(); System.out.println("Enter the second number"); int secondnum = scan.nextInt(); System.out.println("are you adding, subtracting multiplying or dividing? ENTER +,*,-, or /"); String operand = scan.next(); if(operand.equals("+"))< int solution = firstnum + secondnum; System.out.println(firstnum + operand + secondnum + "=" + solution); >else if (operand.equals("*")) < int solution = firstnum * secondnum; System.out.println(firstnum + operand + secondnum + "=" + solution); >else if(operand.equals("-")) < int solution = firstnum - secondnum; System.out.println(firstnum + operand + secondnum + "=" + solution); >else if(operand.equals("/")) < int solution = firstnum / secondnum; System.out.println(firstnum + operand + secondnum + "=" + solution); >else < System.out.println("Did not recognize operation type please restart program."); return; >> else if(choice == 2) < System.out.println("Advanced equation"); System.out.println("How many numbers are in your equation? max of 7\n" + "operands are chosen by typing +,-,*,or /"); int numofnumbers = scan.nextInt(); if(numofnumbers == 2)< System.out.println("enter first num"); int firstnum = scan.nextInt(); System.out.println("enter second num"); int secondnum = scan.nextInt(); System.out.println("enter operand"); String operand = scan.next(); if(operand.equals("+"))< int solution = firstnum + secondnum; System.out.println(firstnum + operand + secondnum + "=" + solution); >else if (operand.equals("*")) < int solution = firstnum * secondnum; System.out.println(firstnum + operand + secondnum + "=" + solution); >else if(operand.equals("-")) < int solution = firstnum - secondnum; System.out.println(firstnum + operand + secondnum + "=" + solution); >else if(operand.equals("/")) < int solution = firstnum / secondnum; System.out.println(firstnum + operand + secondnum + "=" + solution); >else < System.out.println("Did not recognize operation type please restart program."); return; >> else if(numofnumbers == 3) < System.out.println("enter first num"); int firstnum = scan.nextInt(); System.out.println("enter second num"); int secondnum = scan.nextInt(); System.out.println("enter thir num"); int thirdnum = scan.nextInt(); >else if(numofnumbers == 4) < System.out.println("enter first num"); int firstnum = scan.nextInt(); System.out.println("enter second num"); int secondnum = scan.nextInt(); System.out.println("enter third num"); int thirdnum = scan.nextInt(); System.out.println("enter fourth num"); int fourthnum = scan.nextInt(); >else if(numofnumbers == 5) < System.out.println("enter first num"); int firstnum = scan.nextInt(); System.out.println("enter second num"); int secondnum = scan.nextInt(); System.out.println("enter third num"); int thirdnum = scan.nextInt(); System.out.println("enter fourth num"); int fourthnum = scan.nextInt(); System.out.println("enter fifth num"); int fifthnum = scan.nextInt(); >else if(numofnumbers == 6) < System.out.println("enter first num"); int firstnum = scan.nextInt(); System.out.println("enter second num"); int secondnum = scan.nextInt(); System.out.println("enter third num"); int thirdnum = scan.nextInt(); System.out.println("enter fourth num"); int fourthnum = scan.nextInt(); System.out.println("enter fifth num"); int fifthnum = scan.nextInt(); System.out.println("enter sixth num"); int sixthnum = scan.nextInt(); >else if(numofnumbers == 7) < System.out.println("enter first num"); int firstnum = scan.nextInt(); System.out.println("enter second num"); int secondnum = scan.nextInt(); System.out.println("enter third num"); int thirdnum = scan.nextInt(); System.out.println("enter fourth num"); int fourthnum = scan.nextInt(); System.out.println("enter fifth num"); int fifthnum = scan.nextInt(); System.out.println("enter sixth num"); int sixthnum = scan.nextInt(); System.out.println("enter seventh num"); int seventhnum = scan.nextInt(); >> else
stackoverflow.com/questions/29224513/… this question of mine also needs another answer. i got one answer solved from it but it still isent working right so it would be nice if i could get some suggestions for that problem too
Instead of limiting your program to very specific input, you should think about how you can take a typical mathematical expression as a string and parse/evaluate it. Take a look here stackoverflow.com/questions/13662001/…
1 Answer 1
I love this challenge because it is so central to what computers were made for in the first place, calculating equations! What helps me to think about first is how the computer itself generally performs these kinds of operations. As I understand it the computer does one operation at a time (you got that part right!) and then stores that result and essentially re-evaluates the remaining problem as if that operation had already been done.
In order to do this kind of thing in java I think it is best to familiarize yourself with a couple concepts such as ArrayList and String.split.
You need ArrayList to hold the problem instead of the more traditional array because the length of the problem is going to change throughout the program as we can see above with the 4+3+2 example. So if you were to try to cycle through an array with a for loop but the array needs to keep getting shorter, this can all become very complicated.
ArrayList is an awesome object that provides us with an dynamic «form» of array that has all kinds of helpful methods.
You can declare an ArrayList like this.
ArrayList *Name* = new ArrayList();
And then you can use a bunch of different methods such as .add to add an item to the end of the list (increasing the length by 1), .remove to remove an item (and its containing index decreasing the length by 1), and .get(idx) which replaces Array[idx].
Now you are going to want to store your operators in the same object as your operands because you want to maintain their order. In order to do this your best bet is to store the whole entry as a String, like a sentence, and then later you can split the whole thing up. This is where String.split comes in.
You can check out this awesome entry on its use:
You can return an array that contains each number next to its operator in sequence.
Now this is very important!!
You cannot put the array returned from a split directly into an arraylist! You must store it in a traditional array first, and then you can «feed» it into an ArrayList using a for loop and ArrayList.add().
Now I’m not going to solve this for your, as I’m sure you’ll want to figure it out yourself. But feel free to hit me up!
Oh and last couple things. You are going to need .parseToDouble to convert the strings in the ArrayList back into doubles, and .toString to convert them back into strings and place them back into ArrayList.
Oh and you should learn to write and call methods, will make your life a lot easier in terms of organization.
For example in main instead of:
double result; double a; double b; result = a+b
As long as your write the method beneath main:
public double add(double x, double y)
May seem like more typing at first but when you get used to writing methods like that you will find your overall code getting shorter and shorter
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
A calculator created in 2020 as a project for my Java introductory course in the British University in Dubai
Mayonaka88/java-advanced-calculator
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
A calculator created in 2020 as my project for the Java introductory course in the British University in Dubai.
Java was used in this project.
The calculator is entirely operated on the terminal.
The program is comprised of one file.
The calculator has 5 modes which are the Basic Calculator, the Statistical Calculator, the Matrix Calculator, the Geometeric Calculator, and the Mini Games.
In total, there are 30 operations that can be preformed.
An issue with this project is that it does not contain any comments however the code is readable enought to be utilized.
I suggest running the code and exploaring its capabilities because even though it is such a small project it still has many impressive capabilities like backtracking and the ability to process matrices all in the terminal.
About
A calculator created in 2020 as a project for my Java introductory course in the British University in Dubai
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
aepikalov/JavaPatterns_2_1_Structural
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
В этом задании попрактикуемся с шаблоном Adapter (Адаптер). Ниже вам дан готовый класс калькулятора:
public class Calculator < public Formula newFormula() < return new Formula(); > public static enum Operation < SUM, SUB, MULT, DIV, POW; > public static class Formula < protected Double a, b, result; protected Formula() <> public Formula addOperand(double operand) < if (a == null) < a = operand; > else if (b == null) < b = operand; > else < throw new IllegalStateException("Formula is full of operands"); > return this; > public Formula calculate(Operation op) < if (a == null || b == null) throw new IllegalStateException("Not enough operands!"); switch (op) < case SUM: result = a + b; break; case SUB: result = a - b; break; case MULT: result = a * b; break; case DIV: result = a / b; break; case POW: result = Math.pow(a, b); break; > return this; > public double result() < if (result == null) throw new IllegalStateException("Formula is not computed!"); return result; > > >
Пример использования этого класса:
Calculator calc = new Calculator(); System.out.println( calc.newFormula() .addOperand(5) .addOperand(15) .calculate(Calculator.Operation.MULT) .result() );
Пользователю же нужен другой интерфейс для работы с калькулятором:
public interface Ints < int sum(int arg0, int arg1); int mult(int arg0, int arg1); int pow(int a, int b); >
который он использует в main , например, вот так:
public static void main(String[] args) < Ints intsCalc = new IntsCalculator(); System.out.println(intsCalc.sum(2, 2)); System.out.println(intsCalc.sum(10, 22)); System.out.println(intsCalc.pow(2, 10)); >
Вам надо написать класс IntsCalculator , который будет имплементировать интерфейс Ints , «под капотом» делая вычисления через класс Calculator .
- Создайте класс Calculator , скопируйте его готовый код выше.
- Создайте интерфейс Ints , скопируйте его готовый код выше.
- Создайте класс IntsCalculator , укажите что он имплементирует интерфейс Ints , реализуйте его методы через обращение к объекту класса Calculator :
public class IntsCalculator implements Ints < protected final Calculator target; public IntsCalculator() < this.target = new Calculator(); > @Override public int sum(int arg0, int arg1) < //считаем через target > @Override public int mult(int arg0, int arg1) < //считаем через target > @Override public int pow(int a, int b) < //считаем через target > >
- Создайте класс Main , продемонстрируйте использование и возможности вашего класса (например, как выше в условии), обращайтесь к нему как к объекту интерфейса Ints .
public class Main < public static void main(String[] args) < Ints calc = new IntsCalculator(); //демонстрация > >
- Протестируйте работу программы. Не забывайте про правила форматирования кода (для автоформата можете выделить код в идее и нажать Ctrl+Alt+L).