Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

1. ## HELP! Deadline tomorrow! JAVA CALC

Code:
```	valoareTreceri = parseInt(\$('#treceri1').attr('value'));
if(!valoareTreceri) {
valoare1 = 0;
} else {
if(tip=='tip1'||tip=='tip3') {
valoare1 = f8*1.25*(0.3*(valoareTreceri-1)+1);
}
}```
I have this java code that calculates "valoare1" as the multiplication of f8 (f8 is a value given earlier in the code) with 1.25 then with 0.3 * "valoareTreceri" wich is a value from 0 to 6 (default 0) taken from html form.
ex: if valoareTreceri=4 then
valoare1=15*1.25*(0.3*(4-1)+1) =
=15 * 1.25 * (1.9)= 35.62
if valoaretreceri=5 then
valoare1=15*1.25*(0.3*(5-1)+1)=
=15 *1.25* (2.2) = 41.25
So what happens is that valoare1 gets + 30% when valoareTreceri rises.

I need that "valoare1" for each "valoareTreceri" (from 1 to 6) to be a fix value. Not to rise procentual. And to define it manualy for each 1 to 6.
For example something like this: (the numbers are fictive)
if valoareTreceri=1
valoare1=f8+5
if valoareTreceri=2
vlaoare1=f8+19
if valoareTreceri=3
valoare1=f8+20
if valoareTreceri=4
valoare1=f8+38
etc until 6

This valoareTreceri is selected by user in html form and depending to it the price of product changes but not procentual as it is now.

If you want to look at the calculation form or the entire code by inspecting element you`ll find it here: www.armedia.ro/test
If i didn`t make myself clear i can give further explications. It`s late and I`m tired.

• Is this code supposed to be Java or is it supposed to be JavaScript? You are asking about Java but have posted in the JavaScript forum. These are two completely different languages but from what you have posted it is difficult to say which of the two you are trying to use (although the first line of the code does look like poorly written JavaScript).

• I don't get it.

Why did you give this example:
Code:
```if valoareTreceri=4 then
valoare1=15*1.25*(0.3*(4-1)+1) =
=15 * 1.25 * (1.9)= 35.62
if valoaretreceri=5 then
valoare1=15*1.25*(0.3*(5-1)+1)=
=15 *1.25* (2.2) = 41.25```
Which of course could be done without any "if"s as simply:
Code:
`valoare1=15*1.25*(0.3*(valoareTreceri-1)+1);`
And then change your mind and give these:
Code:
```if valoareTreceri=4
valoare1=f8+38
... etc. ...```
Which is it?

•