Can someone tell me how to use Math .ceil in this html. I cant seem to get it to round the tip amount.( for a school assignment)


<!doctype html>
<!-- tip.html                             josh weaver -->
<!-- this web page calculates the tip amount on bill. -->
<!-- ================================================ -->

<title> Tip Calculator </title>

<h2>tip calculater</h2>
Enter Check amount : $<input type="text" id="amountBox" size=10 value="">
Tip percentage : 15%
<input type="button" value="Calculate tip"
tip = amount * (15/100);
'you should tip $' + tip;">
<div id="outputDiv"></div>


That depends, what are you trying to achieve? If you want it to show in the output, you can simple call it in the output:

'you should tip $' + Math.ceil(tip);">

But of course, this depends on what you want to achieve


Thank you . attempting to get it to give me the tip amount rounded to the second decimal place..


Why then, not simply use math.round?


It only wants it to round up , vs the math.round which goes either way


well, next time, could you in one time specify what you are trying to achieve? I haven't tested many values, but this seems to do fine:

tip = Math.ceil(amount * 15) / 100;

only problem, if people enter: 0.00001 this will still say you need to tip 0.01


SURE Thanks for you help