calculator

i cant get my calculator to work

妖精的绣舞 提交于 2019-12-13 22:50:16
问题 i want to input a int to get first number then use a string to get the operator and another int for the second number. user should input some thing like 10+20. but as soon as i enter the "+" then i get an error why? cuz it works if i manually add the values into the sum.calc(); myself like sum.calc(12, "+", 24); then it works ill get 36 PART 1: import java.util.Scanner; public static void main(String[] args) { math sum = new math(); Scanner input = new Scanner(System.in); double a = input

Reading Characters from StdIn [closed]

老子叫甜甜 提交于 2019-12-13 11:27:14
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 years ago . public class New { public static void main(String[] args) { System.out.println("Calculator"); float a = StdIn.readFloat(); char sign = StdIn.readChar(); float b = StdIn.readFloat(); float c = 0; if (sign == '+') c = a+b; else if (sign == '-') c = a-b; else if (sign == 'x') c = a*b; else if (sign ==

Java Jsp Servlet Calculator

喜你入骨 提交于 2019-12-13 11:18:28
问题 This should be a simple Jsp servlet calculator wich insn't working. Maybe I am blind but I think I miss something. Can someone help me? I have a servlet: package com.service.servlet; import java.io.IOException import java.util.Map; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;

String index out of range when accessing chars in a String

岁酱吖の 提交于 2019-12-13 11:13:11
问题 I'm trying to make an RPN calculator. I have done the conversion from infix to postfix, now I want to evaluate the converted expression. When I enter any expression I get error String index out of range: 1. Here's my code with what I'm supposed to do in the program: static int eval(String postfix) { int result = 0; String temp2 = ""; int num1, num2, OPS; char operator; String delete = ""; for (int i = 0; i < postfix.length(); i++) { char M = postfix.charAt(i); // if v_i is an operand: Push v

How can I get the text from textField (JavaFX)

[亡魂溺海] 提交于 2019-12-13 10:23:49
问题 I'm building a calculator and I need to do a general event handler for buttons. Following questions are stopping me: How can I make it so it only works when a button is pressed, not outside of window. How can I store the displayed value? When I press 1 more than once, it doesn't keep going. It maintains only 1 digit and I need like: 111111 Thank you This is what I have so far, but it doesn't work: scene.addEventFilter(MouseEvent.MOUSE_PRESSED, new EventHandler<MouseEvent>() { @Override public

javascript help using html and calculator

蓝咒 提交于 2019-12-13 09:47:39
问题 Can someone help me to get the total price of the stock given prices below?? Using the onclick, once someone puts in the number of stocks they want to buy, how do I go about getting the total price of all 3 stocks choosen?? <tr> <td><b> SHARE PRICE</b></td> <td>$43.93</td> <td>$43.87</td> <td>$26.33</td> </tr> </table> <hr> <br> <p> <h3>Important information that you should know about these stocks: </h3> <ul> <li>0.1% of the trade value if the total trade value is less than $10,000</li> <li>0

Python: I'm making a simple calculator for class. What's wrong with this code?

只愿长相守 提交于 2019-12-13 09:41:17
问题 My teacher requests me to make a calculator that can calculate a 15% tip on a submitted price. I followed an online tutorial for this python application. I made a simple addition, subtraction, multiplication, and division calculator for practice before I make what my teacher requires. In the YouTube video I followed the python application ran on his computer. I get a a "Invalid Syntax" error in the Python Shell. I'm using Python 3.3.0. Thank you. EDIT: I followed a different tutorial figured

How can I make a simple calculator in python 3?

巧了我就是萌 提交于 2019-12-13 09:39:46
问题 I'm making this calculator using python 3, and this is what I have so far: print("Welcome to Calculator!") class Calculator: def addition(self,x,y): added = x + y return added def subtraction(self,x,y): subtracted = x - y return subtracted def multiplication(self,x,y): multiplied = x * y return multiplied def division(self,x,y): divided = x / y return divided calculator = Calculator() print("1 \tAddition") print("2 \tSubtraction") print("3 \tMultiplication") print("4 \tDivision") operations =

32 bit Calculator in 8086 Assembly

你说的曾经没有我的故事 提交于 2019-12-13 08:58:31
问题 CALCULATOR 32 Bit Can someone help me with my 32 bit calculator in MASM32. i think the adding and subtracting is OK but i cant print the number in decimal; 0002FFFF - 10005 = 1fffa In MEMORY :0001 0FFFA PRINTING: 165530 in decimal DATA_HERE SEGMENT mult1 dw 0002H dw 0FFFFH mult2 dw 0001H dw 0005H ans dw 0,0 DATA_HERE ENDS STACK_HERE SEGMENT STACK DW 40 DUP(0) STACK_HERE ENDS CODE_HERE SEGMENT ASSUME CS:CODE_HERE, DS:DATA_HERE, SS: STACK_HERE INICIO: MOV AX,DATA_HERE MOV DS,AX ADD: MOV AX

How to make calculator round to nearest tenth

旧街凉风 提交于 2019-12-13 08:05:21
问题 I am building a calculator but when you start with decimals it won't round to the nearest tenth like I want it to. Anyone's help would be greatly appreciated. https://fuzzyandroidblog.wordpress.com/ I added it here wouldn't let me post for some reason thanks for help 回答1: Use a NumberFormat with maximum fraction digits of 1 to format a floating point value to a string representation with at most one number after the decimal point. 来源: https://stackoverflow.com/questions/27422365/how-to-make