Can someone help me make my calculator work?
I am stuck at this problem:
x/z = 320
y/z = 426.6666666666667
The numbers I wrote I got by calculating other stuff but my problem is that x and y can only be hundreds and there is a limit: 3000.
In other words, I need to limit the choices for x and y to 30 numbers (100, 200, 300, ..., 3000).
Z must have a rule as well but no limit. How to make a rule to choose only from numbers with 1 number after comma? eg. 0.9, 1, 1.1, 1.2, 1.3, etc.?
The point of my calculator is to check if there are possible combinations of numbers with given rules and limitations.
Calculator Topic is solved
-
- Posts: 141
- Joined: 19 Jul 2017, 09:59
-
- Posts: 141
- Joined: 19 Jul 2017, 09:59
Re: Calculator
I don't understand how ;-;
Re: Calculator
Can you give some examples for x,y,z?
Btw 'with 1 number after comma (dot)', I believe you mean numbers with 1 decimal place.
This code might do something similar to what you want:
Btw 'with 1 number after comma (dot)', I believe you mean numbers with 1 decimal place.
This code might do something similar to what you want:
Code: Select all
q::
vLimX := vLimY := 3000
Loop
{
vZ := 0.8+A_Index*0.1
Loop
{
vY := A_Index*100
if (vY > vLimY)
break
Loop
{
vX := A_Index*100
if (vX > vLimX)
break
vOutput1 := vX "/" vZ "=" (vX/vZ)
vOutput2 := vY "/" vZ "=" (vY/vZ)
if (vX/vZ > 300) && (vX/vZ < 350)
&& (vY/vZ > 400) && (vY/vZ < 450)
MsgBox, % vOutput1 "`r`n" vOutput2
}
}
}
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
-
- Posts: 141
- Joined: 19 Jul 2017, 09:59
Re: Calculator
Ok, this is the whole process with working numbers:
List of numbers that ahk can choose from when checking x and y.
100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500,1600,1700,1800,1900,2000,2100,2200,2300,2400,2500,2600,2700,2800,2900,3000
List of numbers that ahk can choose from when calculating z.
0.1,0.2,0.3,... (Numbers with 1 decimal place, range from 0 to 5)
Solved example:
List of numbers that ahk can choose from when checking x and y.
100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500,1600,1700,1800,1900,2000,2100,2200,2300,2400,2500,2600,2700,2800,2900,3000
List of numbers that ahk can choose from when calculating z.
0.1,0.2,0.3,... (Numbers with 1 decimal place, range from 0 to 5)
Solved example:
Code: Select all
Let's say we input values:
600
800
600 := x*z
800 := y*z
Ahk calculates possible combinations and posts results:
x=600
y=800
z=1.0
x=300
y=400
z=2.0
x=1200
y=1600
z=0.5
etc
Re: Calculator
Well, I've got some nice code for this. A school/university assignment? A real-world problem? Cheers.
Code: Select all
q::
vLimX := vLimY := 3000
vLimZ := 5
Loop
{
vZ := Format("{:0.2f}", A_Index*0.01)
if (vZ > vLimZ)
break
Loop
{
vY := A_Index*100
if (vY > vLimY)
break
Loop
{
vX := A_Index*100
if (vX > vLimX)
break
vOutput1 := vX "/" vZ "=" (vX/vZ)
vOutput2 := vY "/" vZ "=" (vY/vZ)
if (vX/vZ = 320)
&& (vY/vZ > 420) && (vY/vZ < 430)
MsgBox, % vX " " vY " " vZ "`r`n" vOutput1 "`r`n" vOutput2
}
}
}
MsgBox, % "done"
return
;==================================================
w::
vLimX := vLimY := 3000
vLimZ := 5
vOutput := ""
Loop
{
vZ := Format("{:0.2f}", A_Index*0.01)
if (vZ > vLimZ)
break
Loop
{
vY := A_Index*100
if (vY > vLimY)
break
Loop
{
vX := A_Index*100
if (vX > vLimX)
break
if (vX*vZ = 600)
&& (vY*vZ = 800)
vOutput .= vX " " vY " " vZ "`r`n"
}
}
}
Clipboard := vOutput
MsgBox, % vOutput
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
-
- Posts: 141
- Joined: 19 Jul 2017, 09:59
Re: Calculator
Oh man, it works perfectly! I already grasp a little how it works and I can find values if I type it manually. Thank you!jeeswg wrote:Well, I've got some nice code for this. A school/university assignment? A real-world problem? Cheers.
Spoiler
BUT
For calculator to work I must be able to place different variables each time I run the script.
I tried moving them to replace numbers like this:
if (vX*vZ = %var1%)
&& (vY*vZ > %var2%-1) && (vY*vZ < %var2%+1)
I get error code " 600.00000 is not a valid number" and ahk closes. Why does it crash and is this expression (%var2%+1) correct?
Re: Calculator Topic is solved
Just remove the % signs, that should work:
Code: Select all
if (vX*vZ = var1)
&& (vY*vZ > var2-1) && (vY*vZ < var2+1)
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
-
- Posts: 141
- Joined: 19 Jul 2017, 09:59
Re: Calculator
jeeswg wrote:Just remove the % signs, that should work:Code: Select all
if (vX*vZ = var1) && (vY*vZ > var2-1) && (vY*vZ < var2+1)
You're a genius! Thank you!
Who is online
Users browsing this forum: Bing [Bot], mikeyww and 237 guests