calculator

How to arrange multiple panels in JFrame

瘦欲@ 提交于 2019-12-05 22:59:12
问题 I am trying to make a simple calculator to practice Graphics (i am a complete GUI noob). I am having some problems with having unneeded spaces after Polyashenkos Calulator and the text area and the space between the text area and the buttons. Also how do i keep that layout but eliminate the space and also make the bottom 3 buttons smaller. Any tips about what im doing or how i can do it better would be much appreciated. Thank you. import javax.swing.*; import java.awt.*; public class

How to make a wacky math calculator? (Preferably in c++ but others are ok too.)

百般思念 提交于 2019-12-05 20:16:59
I would like to know how to do some lower-level thing in C++ that will allow me to do some "wacky" math operations. Specifically my two questions are: 1) How can I define my own math symbol that the compiler will be able to recognizes in my code . In other words, I'm not looking to parse a string from a user, but rather have the compiler recognize this as a new math operation. ex: 3 {+} 4 will actually do 3 – 4 etc. 2) How can I define a custom number from an ASCII symbol. For example, define the symbol # to be recognized by the compiler as 18 (i.e. 00010010 in binary). ex: 18 {+} # = 18 - 18

Graphing calculator: how to find the appropriate part of the graph to show

有些话、适合烂在心里 提交于 2019-12-05 18:52:08
I am working on a graphing calculator (you know, one where you type in a formula, let's say x^2 and you get the graph of that function). The problem I am having is how to offset and scale the view of graph as to show the interesting section of the function. I have exhausted all the 'simple' ideas I have had. Let me show some example: - sin(x) => interesting section is between y = [-1,1] and offset (0,0) - x^2 => interesting section is between y = [0, 100] and offset is (0,0). (100 has been picked arbitrarily) - 100x^2 - 10000 => y = [-10000, 100*] and offset is (-10000, 0) I figured I could

Best coding language for dealing with large numbers (50000+ digits)

元气小坏坏 提交于 2019-12-05 17:36:10
Can you recommend good languages to do math with large numbers in? So far I've used Actionscript 2 and Objective-c and with Objective-c even using NSDecimalNumbers I was limited to 32 digits in my calculations... I would need at a minimum to be able to calculate with numbers fifty-thousand digits long. Perhaps Haskell will appeal to you. Python has arbitrary-length integers and uses them transparently, so you don't need any special code or classes for this. >>> len(str(math.factorial(123456))) 574965 Try also bc , which is probably already installed in your machine. Try java with its

Java Simple Calculator

廉价感情. 提交于 2019-12-05 11:59:03
I have made this calculator program in Java. This works well only when two numbers are calculated at one time. That means to get the sum of 1+2+3 you have to go this way : press 1 press + press 2 press = press + press 3 press = and it calculates it as 6. But I want to program this so that I can get the answer by: press 1 press + press 2 press + press 3 press = but this gives the answer 5!!! How to code this so that it works like an ordinary calculator? Here is my code: import java.awt.*; import java.awt.event.*; import javax.swing.*; public class cal1 extends JFrame { double op1 = 0d, op2 = 0d

Creating backspace on iOS calculator

二次信任 提交于 2019-12-05 08:00:30
问题 I'm trying to add a backspace button to remove the last entered digit in a calculator, but I can't seem to get it. Here is what I've tried: -(IBAction)backspacePressed:(UIButton *)sender { NSMutableString *string = (NSMutableString*)[display text]; int length = [string length]; NSString *temp = [string substringFromIndex:length-1]; [display setText:[NSString stringWithFormat:@"%@",temp]]; } Any ideas? 回答1: I think you want [string substringToIndex:length-1] instead of [string

Why does pow(5,2) become 24? [closed]

五迷三道 提交于 2019-12-04 22:11:28
I'm making a simple calculator that you can choose a function, then 2 inputs to get your answer. It's a neat little program and everything is running smoothly except for the powers. Every number works correctly. But according to this: 5^2=24, 5^3=624 . I am using pow(number1,number2) . #include <iostream> #include<math.h> using namespace std; int main() { for(;;){ int func; int number1; int number2; cout << "Input your function (+,-,x,/,Square,Power)(1,2,3,4,5,6) "; cin >> func; cout << "input #1: "; cin >> number1; cout << "input #2: "; cin >> number2; if (func==1){ int answer; answer =

Simple Calculator with multiple operations - Android

狂风中的少年 提交于 2019-12-04 16:32:28
I have created a simple calculator that calculates two inputs (ex. 2 + 2 = 4). What I want to do now is to make the app to calculate multiple operations like (ex. 2 + 2 * 4 - 1 = 15). Can someone help me with my code? Here is my code. public class MainActivity extends Activity { public String str =""; Character op = 'q'; int i,num,numtemp; EditText showResult; String displayStr = ""; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE

Logarithm Calculation with Windows 7 Calculator [closed]

帅比萌擦擦* 提交于 2019-12-03 14:58:52
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 years ago . I would like to use the Windows Calculator in Scientific Mode in order solve a very basic Logarithm equation but, unfortunately, I couldn't do that. Here is the problem: log_5 125=? Thank you very much for your help... Well, I know it equals to "3", but, how can I use the Windows Calculator to get computed that

Logarithm Calculation with Windows 7 Calculator [closed]

会有一股神秘感。 提交于 2019-12-03 04:43:35
I would like to use the Windows Calculator in Scientific Mode in order solve a very basic Logarithm equation but, unfortunately, I couldn't do that. Here is the problem: log_5 125=? Thank you very much for your help... Well, I know it equals to "3", but, how can I use the Windows Calculator to get computed that equation for example? Shay You can calculate a logarithm in a given base by calculating two logarithms in an arbitrary base, using the following equation: log_b (x) = log_k (x) / log_k (b) As the windows calculator got a ln button, which stands for the natural logarithm (that is, log in