Good morning, guys, I have this job to do and deliver tomorrow in the tutorial, but I'm completely lost in how to work out this in notepad ++. Could you please give me a light? I've been trying since 2:00 am and I can not. Thank you in advance.
Create an HTML form with javascript with the following fields:
-
Product value (text field); quantity (text field)
-
The program should calculate the total cost (quantity x value of the product);
-
The program should calculate the profit on each product (product value x 65%);
-
The program should calculate total profit (profit x quantity);
-
The program should calculate taxes on each product (product value + profit x 18.7%);
-
The program should calculate the total tax (taxes * quantity);
-
The program should calculate the sales price (product value + profit + tax);
-
Print all calculations within one paragraph (
)
<title>Trabalho</title>
<script>
function calcularImposto(){
resultado = document.getElementById("resultado");
n1 = document.getElementById("n1").value;
imposto1 = parseFloat(n1)*0.22;
imposto2 = parseFloat(n1)*0.18;
resultado.innerHTML = "imposto 1" + imposto1 + "<br /> Imposto 2 " + imposto2;
}
</script>
</head>
<body>
<form>
<label>Número 1:</label>
<input type="text" name="n1" id="n1" size="5" />
<br />
<input type="button" name="botao" id="botao" value="Calcular" onclick="calcularSoma()" />
</form>
<p>Resultado: <span id="resultado"> 0 </span></p>
</body>
This is the code that the teacher passed as an example to help with the work itself. My question is how to adapt this code to the exercises. I thought of doing with some variables like this:
var quantidade, produto
var lucro, imposto
var totalCusto, totalImposto, totalLucro
var precoVenda
custo total = quantidade * produto
lucro = (produto / 100) * 65
imposto = ((produto + lucro) / 100) * 18,7
totalLucro = lucro * quantidade
totalImposto = imposto * quantidade
precoVenda = produto + lucro + imposto
But I do not know if it would work. I missed some classes because of work and now I'm kind of desperate.