calculator

How to create a Sports Bet Calculator using javascript

拜拜、爱过 提交于 2020-02-08 11:35:29
问题 I have created this simple straight bet calculator using JavaScript. It allows me to calculate, if it is a winning ticket, how much the payout will be. How it works? First I will enter the moneyLine number, which can be mostly any 3 digits number and I then enter the bet amount. Now, the moneyLine can either be negative (-) if betting a favorite or positive (+) if betting the underdog. Please see the code below: For testing proposes, I use any -110 or 110 and then, any bet amount. But it can

How to convert textField.text value to Integer and sum two Integers

孤者浪人 提交于 2020-02-04 04:42:25
问题 Initialization of immutable value 'textfieldInt' was never used; consider replacing with assignment to '_' or removing it and textfield2Int I get that warning twice for textfieldInt This is all the code I have: class ViewController: UIViewController { @IBOutlet weak var textField1: UITextField! @IBOutlet weak var textField2: UITextField! @IBOutlet weak var output: UILabel! @IBAction func calculate(_ sender: AnyObject) { let textfieldInt: Int? = Int(textField1.text!) let textfield2Int: Int? =

Using “If Statements” in basic C programming. How can I properly format them?

佐手、 提交于 2020-01-26 04:13:19
问题 To begin, the code that I have got up to this point is below. The calculator does everything I want it to, minus the fact that it still includes negative numbers in its calculations. I would like for it to do nothing if the number presented as the radius is less than zero, yet still calculate if the number is non-negative. However, I am having issues with using an if statement. I have not used these before, as I am really just a beginner. I just need a push in the right direction. Do I need

Can anyone help me check my BMI Calculator? (C#)

萝らか妹 提交于 2020-01-21 18:59:28
问题 I just started programming a week ago and my first assignment was to code a BMI calculator. It is supposed to look like this when launched: BMI Calculator Your weight in kg: x Your height in cm: x Gender (m/f): x -> You are underweight/normal/overweight Here is my code so far: Console.WriteLine("BMI Calculator"); Console.WriteLine("==========="); Console.WriteLine(); Console.Write("Weight in kg: "); int kg; kg = Convert.ToInt32(Console.ReadLine()); Console.Write("Height in cm: "); int m; m =

Can anyone help me check my BMI Calculator? (C#)

耗尽温柔 提交于 2020-01-21 18:58:45
问题 I just started programming a week ago and my first assignment was to code a BMI calculator. It is supposed to look like this when launched: BMI Calculator Your weight in kg: x Your height in cm: x Gender (m/f): x -> You are underweight/normal/overweight Here is my code so far: Console.WriteLine("BMI Calculator"); Console.WriteLine("==========="); Console.WriteLine(); Console.Write("Weight in kg: "); int kg; kg = Convert.ToInt32(Console.ReadLine()); Console.Write("Height in cm: "); int m; m =

Java fraction calculator

二次信任 提交于 2020-01-14 13:34:11
问题 I'm really new to Java programming and I have an assignment due for my AP Computer Programming class, so bear with me. I have to figure out how to multiply two fractions together. I was wondering if there was any way to declare a variable inside a method and use it outside that method (my while loop in the intro method). Thank you, hope that wasn't confusing! import java.util.Scanner; import java.util.StringTokenizer; public class javatest3 { static int num1 = 0; static int num2 = 0; static

adding / dividing / multiplying numbers and operators from array in javascript without eval()

坚强是说给别人听的谎言 提交于 2020-01-11 14:50:15
问题 I'm making a calculator. And the challenge is not to use eval() . I made an array from all the inputs that looks like this: numbers = [1,1,'+',2,'*',3,'-','(',4,'*',5,'+',2,'/',5,')']; Then i convert this array to a string, remove the , and i get a string like this: numberString = "11+2*3-(4*5+2/5)"; So my question is, what is the way to correctly calculate the result of this equation without using eval() ? 回答1: Use an object to map operator strings to functions that implement the operator.

adding / dividing / multiplying numbers and operators from array in javascript without eval()

一世执手 提交于 2020-01-11 14:50:08
问题 I'm making a calculator. And the challenge is not to use eval() . I made an array from all the inputs that looks like this: numbers = [1,1,'+',2,'*',3,'-','(',4,'*',5,'+',2,'/',5,')']; Then i convert this array to a string, remove the , and i get a string like this: numberString = "11+2*3-(4*5+2/5)"; So my question is, what is the way to correctly calculate the result of this equation without using eval() ? 回答1: Use an object to map operator strings to functions that implement the operator.

Price Calculator based on Quantity [closed]

梦想的初衷 提交于 2020-01-11 14:40:11
问题 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 6 years ago . I am trying to create a simple script to add to my html website. I need it to calculate the price based on the quantity the user inputs. For example, a value of 1-1000 will be multiplied by 1.50 and displayed, 1001-5000 multiplied by 1.20 and displayed, 5001-10000 multiplied by 1 and displayed and any number

How to have a number to be a power?

有些话、适合烂在心里 提交于 2020-01-11 10:06:31
问题 My Javascript has this: (A + B) ? C I have everything else, but how do i have C to be a power? I thought using ^ would work, but it just adds it. 回答1: JavaScript does not have an operator for exponentiation. ^ is actually the bitwise XOR operator. Try using Math.pow instead: var d = Math.pow(a + b, c); 来源: https://stackoverflow.com/questions/21861908/how-to-have-a-number-to-be-a-power