Start by learning what the javascript is (and what it isn't). (by this sentence I originally refer to the fact that the question was tagged both Java and JavaScript)
I'm afraid you've expected that someone could post you whole code that you can copy and paste. I will disappoint you - this is a knowledge site, not a coding machine.
While I did not understand what exactly you want to do (and I doubt anyone did) I can give you a few hints on How to start? phase of thing.
I assume you have read what javascript is here:
To let the user input numbers, create HTML input elements (outside of the script):
<input type="text" id="UNIQUE_ID" value="" />
<button onclick="click()">Click when done!</button>
<script> ... put the code between script tags... </script>
I have declared that whenever the <button>
is clicked ("onclick") the function click()
will be called. Let's create click()
:
function click() {
//We can get an "object" that represents the input field
var field = document.getElementById("UNIQUE_ID");
//We can get the value of said field
var number = field.value;
//We can empty the field now:
field.value = "";
//The number is now string (=text) We need a number. Multiplication forces conversion to number
number = 1*number;
//Check if the number is really a number
if(isNaN(number))
throw new Error("Input is not a number!");
//Do some calculation - for example conversion to hex:
var hexagonal = "0x"+(number).toString(16).toUpperCase();
//Throw the number at the user - nasty but easy
alert(number);
}
Depending on what you want to calculate, you can modify my function. You can also have more fields and more numbers.
I have noticed that for any amount of money you can buy something and charms. Unfortunately summer is hot and my crystal ball has overheated - so I can't let it tell me what charms are.
But to find out how many you can buy:
var gold = 666;
//D'oh an object!
var prices = {
helmet: 150,
armor: 430,
ice_cream: 10,
charm: 9
}
//Define what we want to buy
var wanted = "ice_cream";
//Prevent accessing undefined price
if(prices[wanted]==null)
throw new Error("We don't have this thing in stock yet!");
//Divide the cash by the price to know the amount
var amount = Math.floor(gold/prices[wanted]);
//And calculate spare cash - modulo calculates rest after division
var spare = gold%prices[wanted]
//Finally find out how many charms can be bought with the rest gold
var charms = Math.floor(spare/prices.charm);
//and let the user know
alert("With "+gold+" gold, you can buy "+amount+" "+wanted+"(s) and "+charms+" charms.");
You can run this code without HTML.