basic-calculator | basic-calculator | Apps library
kandi X-RAY | basic-calculator Summary
kandi X-RAY | basic-calculator Summary
basic-calculator
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of basic-calculator
basic-calculator Key Features
basic-calculator Examples and Code Snippets
Community Discussions
Trending Discussions on basic-calculator
QUESTION
So, I challenged myself to create a simple calculator having incorporated a user input system.
The first bit of code (shown below) asks the user what their number is and stores it in a double called "num."
The program then asks the user what they want to do (Add, Subtract, Multiply, Divide, or show the answer) and I put this in a while loop, because I'm thinking that they might want to work with more than 2 numbers. If the user wants the answer, then they'll choose that and the while loop will stop.
My problem is, I want the program to be able to take the number and add, subtract, etc., it with the existing number from before. Essentially, I want the value of the variable to change repeatedly, but I just don't know how to do that.
For example, if the user starts out with the number 2, and adds 2, then multiplies it by 4, the answer should then be 16. I just can't get my code to do that.
I realize that my code is wrong, considering I've tested it, but I just can't wrap my head around what it is I need to do. I feel as though I'm close, but anything can go as I'm still sort of new to Java.
Any help would be appreciated! Thanks!
I think this link could take you to the site to edit it and what not: https://repl.it/@ANGELRAMIREZ6/Basic-Calculator
Here's my code :
...ANSWER
Answered 2019-Feb-26 at 12:29- use println instead of print to flush output, or flush manually
- you only need 1 scanner
- init
answer
to 0 - lines in your switch should alter
answer
QUESTION
So I'm trying to switch from C# console to form, but I always read that never repeat our code etc.
My first project would be a calculator, and I found a site just to take a look how it looks like in win form, but in this code there are a lot of repeating. Is this normal in form, in let's say a calculator?
...ANSWER
Answered 2018-Sep-27 at 23:23That is a lot of repetition, to improve it add one click event handler for all of the buttons, eg:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install basic-calculator
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page