<script type="text/javascript">
$(document).ready(function() {
$("#somar").click(function(){
var total = 0;
var desconto = $("#desconto").val() != "" ? $("#desconto").val() : 0;
$('.input').each(function(){
var valor = Number($(this).val());
if (!isNaN(valor)) total += valor;
});
total = total - desconto;
$(".resultado").html(total.toFixed(2));
});
});
</script>
<script>
function imprimir(mesmo){
var conteudo = mesmo.parentElement.innerHTML,
tela_impressao = window.open('about:blank');
tela_impressao.document.write(conteudo);
tela_impressao.window.print();
tela_impressao.window.close();
}
</script>