calculator

Keyboard Input with swing Java

为君一笑 提交于 2019-12-31 02:15:13
问题 I am working a calculator using java swing and I want to be able to enter the numbers and operations via keyboard. I can't seem to get it working. import java.awt.*; import javax.swing.*; import java.awt.event.*; public class Calculator extends JFrame implements ActionListener { JPanel[] row = new JPanel[6]; JButton[] button = new JButton[23]; JMenuBar menubar = new JMenuBar(); JMenu file = new JMenu("File"); JMenuItem clear = new JMenuItem("Clear"); JMenuItem exit = new JMenuItem("Exit");

Infix Calculator Expression Parser

断了今生、忘了曾经 提交于 2019-12-28 13:58:31
问题 How do I parse and evaluate expressions in an infix calculator grammar? I thought of two ways. The 1st involves using two stacks. One is for numbers and the other is for operators, and I would assess the operator precedence and association in order to figure out how to evaluate an expression. The second method involves converting the infix expression to postfix which I have no idea how I'd go about doing. It was just an idea. Currently I set up my program with the intention to use the 1st

adding in array from stdin

佐手、 提交于 2019-12-26 04:21:51
问题 I am new to java, writing a program just for fun. The purpose of the program is to take in an int via std store in the num [] then add 5 to it. Very simple, how ever I am having issues with my code. To clarify, I am having issues with the actual calculation, how to store the stdin in the int array, then pass it through an addNum method. Thank you. Here is my code: class Array{ public static void main (String [] args) { System.out.println(" enter four digits between 0-100"); Scanner cin = new

adding in array from stdin

浪子不回头ぞ 提交于 2019-12-26 04:21:48
问题 I am new to java, writing a program just for fun. The purpose of the program is to take in an int via std store in the num [] then add 5 to it. Very simple, how ever I am having issues with my code. To clarify, I am having issues with the actual calculation, how to store the stdin in the int array, then pass it through an addNum method. Thank you. Here is my code: class Array{ public static void main (String [] args) { System.out.println(" enter four digits between 0-100"); Scanner cin = new

How to detect the pressed button and display it on Another View? Objective-C

淺唱寂寞╮ 提交于 2019-12-25 19:37:22
问题 I am new to iOS app development. I want to create a Calculator App in iOS that has split view. The left side is the "History" Feature in Scroll View and the right side is the calculator itself. Now, regarding the History feature of this app, I am thinking that my program needs to recognize what has been pressed and display it on the Scroll View when the Equal (=) button is pressed. Do you have any idea how will this go on Objective-C? I am using XCode 4.5 and iPhone Simulator 6.0. Thanks in

How to detect the pressed button and display it on Another View? Objective-C

百般思念 提交于 2019-12-25 19:37:02
问题 I am new to iOS app development. I want to create a Calculator App in iOS that has split view. The left side is the "History" Feature in Scroll View and the right side is the calculator itself. Now, regarding the History feature of this app, I am thinking that my program needs to recognize what has been pressed and display it on the Scroll View when the Equal (=) button is pressed. Do you have any idea how will this go on Objective-C? I am using XCode 4.5 and iPhone Simulator 6.0. Thanks in

Java Calculator Errors

两盒软妹~` 提交于 2019-12-25 17:17:15
问题 I am working on a simple calculator in JAVA as i'm trying to experiment with a GUI. I have run into some errors that still aren't resolved with the debugger.. The buttons on the calculator that represent *,- ans so forth aren't working properly, the only one working properly is the plus button which works properly. The division button never outputs anything, it outputs an error that says that it cant be divided by zero. This is the strangest one because if the input or the number being saved

How to add different actionlisteners to the same object

假装没事ソ 提交于 2019-12-25 11:55:45
问题 How do I add different actionlisteners to the p1 objects. I want the program to be able to set the textbar to the appropriate number when pressed with the appropriate button. Since they are not different variables I cannot simply use the code below(in my actionPerformed function), if (e.getSource() == button1){ txtField.setText("1"); } import java.awt.*; import java.applet.*; import java.awt.event.*; public class Telephone extends Applet implements ActionListener { TextField txtField; public

Proper JS currency format with commas and decimals

纵然是瞬间 提交于 2019-12-25 05:02:02
问题 I have looked through countless threads here and elsewhere for over 2 days and I cannot get this to work properly. I have a calculator working exactly the way I need it to, however, I can't seem to get one last thing complete. Comma separator by thousands with decimal. I have the decimal places, but can't add commas. When I do add commas, I can get one or two fields to work before the calculation breaks or the value is displayed as NaN. Here is the working page: http://codepen.io/anon/pen

python calculator program [closed]

最后都变了- 提交于 2019-12-25 02:16:59
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 7 years ago . I wrote a simple calculator program by using functions, I don't know what exactly wrong with this code, its showing error. I did possible steps to debug