calculator

how to add a localstorage for my Calculator?

家住魔仙堡 提交于 2021-01-29 10:33:55
问题 I have to work on a calculator. I got everything i need. The only thing is, I have to add a LocalStorage under my Result. So the Calculator adds everytime the result, untill i delete the session. For example: "1+1=2," 2*2=4, 8/8=1 Localstorage: 2,4,1 function clear() { number1.value = ""; number2.value = ""; } function clearresult() { result.innerText = ''; } function calc() { var number1 = parseFloat(document.getElementById('number1').value); var number2 = parseFloat(document.getElementById(

Illegal static declaration in inner class while using ActionListener

混江龙づ霸主 提交于 2021-01-29 03:08:12
问题 I'm trying to write a basic calculator GUI program for homework. I'm trying to define a variable for each button pressed on the calculator, and make a calculation when all the variables are declared. Right now, it's only able to add/subtract/divide/multiply two numbers 0-9, but I want to make sure I can get that working before expanding it. My problem is that I get the error code, "Illegal static declaration in inner class Calculator.sign". I'm wondering how I can get past this error. Thanks

Making ruby calculator run continuously

烈酒焚心 提交于 2021-01-29 02:18:05
问题 I have made a simple calculator in ruby. However after running once the program stops and has to be re-run. I tried the following but it ended in an infinite loop. How can I write this so that it will run until the users tells it to quit? puts "Please enter two digits separated by operation you would like to calculate:" input = gets.chomp.split(' ') while input != nil if input[1] == "+" puts input[0].to_i + input[2].to_i elsif input[1] == "-" puts input[0].to_i - input[2].to_i elsif input[1]

Making ruby calculator run continuously

橙三吉。 提交于 2021-01-29 02:16:09
问题 I have made a simple calculator in ruby. However after running once the program stops and has to be re-run. I tried the following but it ended in an infinite loop. How can I write this so that it will run until the users tells it to quit? puts "Please enter two digits separated by operation you would like to calculate:" input = gets.chomp.split(' ') while input != nil if input[1] == "+" puts input[0].to_i + input[2].to_i elsif input[1] == "-" puts input[0].to_i - input[2].to_i elsif input[1]

Java find number of days until your birthday

∥☆過路亽.° 提交于 2021-01-28 18:53:24
问题 Here is a calculator to find how many more days your birthday is in, but when you enter a day that is before today's date, then the calculator will not give you the correct answer. I cannot use import.calender, so how would I solve the problem so that if the birthday was before the date entered that it would give me the correct number of days? import java.util.Scanner; public class Birthdays { public static void main(String[] args) { Scanner newscanner = new Scanner(System.in); System.out

Taking strnig as input for calculator program in Perl

大憨熊 提交于 2021-01-28 10:20:52
问题 I am new to Perl and I'm trying to create a simple calculator program, but the rules are different from normal maths. All operations have the same power and the math problem must be solved from left to right. Here is an example: 123 - 10 + 4 * 10 = ((123 - 10) + 4) * 10 = 1170 8 * 7 / 3 + 2 = ((8 * 7) / 3) + 2 = 20.666 So in the first case the user needs to enter one string: 123 - 10 + 4 * 10. How do i approach this task? I'm sorry if it's too much of a general question, but i'm not sure how

Python Tkinter button not appearing?

℡╲_俬逩灬. 提交于 2021-01-27 17:11:48
问题 I'm new to tkinter and I have this code in python: #import the tkinter module from tkinter import * import tkinter calc_window = tkinter.Tk() calc_window.title('Calculator Program') button_1 = tkinter.Button(text = '1', width = '30', height = '20') button_1 = '1' calc_window.mainloop() But when I run it, the button doesn't appear. Does anyone know why? Thank you! 回答1: Getting a widget to appear requires two steps: you must create the widget, and you must add it to a layout. That means you

Calculate very large number using python

*爱你&永不变心* 提交于 2021-01-05 09:07:13
问题 I'm trying to calculate (3e28 choose 2e28)/2^(3e28). I tried scipy.misc.comb to calculate 3e28 choose 2e28 but it gave me inf. When I calculate 2^(3e28), it raised OverflowError: (34, 'Result too large'). How can I compute or estimate (3e28 choose 2e28)/2^(3e28)? 回答1: Use Stirling's approximation (which is very accurate in the 1e10+ range), combined with logarithms: (3e28 choose 2e28) / 2^(3e28) = 3e28! / [(3e28 - 2e28)! * 2e28!] / 2^(3e28) = e^ [log (3e28!) - log((3e28-2e28)!) - log(2e28!) -

Calculate very large number using python

蹲街弑〆低调 提交于 2021-01-05 09:04:51
问题 I'm trying to calculate (3e28 choose 2e28)/2^(3e28). I tried scipy.misc.comb to calculate 3e28 choose 2e28 but it gave me inf. When I calculate 2^(3e28), it raised OverflowError: (34, 'Result too large'). How can I compute or estimate (3e28 choose 2e28)/2^(3e28)? 回答1: Use Stirling's approximation (which is very accurate in the 1e10+ range), combined with logarithms: (3e28 choose 2e28) / 2^(3e28) = 3e28! / [(3e28 - 2e28)! * 2e28!] / 2^(3e28) = e^ [log (3e28!) - log((3e28-2e28)!) - log(2e28!) -

How to show result with Int on calculator?

孤人 提交于 2021-01-05 07:25:19
问题 I am making the calculator app. It shows double at the result even when I don't use double. Example) 1+1 = 2.0 But I want like 1+1= 2 Of course, I want to keep double when there is double like 1.2+1.3= 2.5 How should I have to edit? I tried to edit like this, but there is an error. public void equalsOnClick(View view) { Integer result = null; ScriptEngine engine = new ScriptEngineManager().getEngineByName("rhino"); try { result = (int)engine.eval(workings); } catch (ScriptException e) { Toast