1 Pages (12 items)
For loop - 1 seat every 30 people - Messages
#1 Posted: 10/11/2021 4:34:23 PM
Hi to everyone, I'm a new user of S-math.
I'm a newbie to programming.
Today I had to make a calculation to size the number of seats in a waiting room according to the total number of people.
The number of seats must be 1 for every 30 people.
I tried to make the calculation automatic via S-math, but I was unable. I thought the for loop might help me, but I don't know how. Can someone help me?
I'm a newbie to programming.
Today I had to make a calculation to size the number of seats in a waiting room according to the total number of people.
The number of seats must be 1 for every 30 people.
I tried to make the calculation automatic via S-math, but I was unable. I thought the for loop might help me, but I don't know how. Can someone help me?
#2 Posted: 10/12/2021 4:25:23 AM
You should start from the problem itself... How would you solve it in mathematical or pseudocode form?
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#3 Posted: 10/12/2021 9:57:04 AM
#4 Posted: 10/12/2021 1:19:00 PM
Hi I try to explain better what I want to calculate.
I would like to set up a for loop that allows me to do the same calculations as the if loop in the figure.

for example
if n.pers < 10 ---> n.s = 1
if n.pers > 10 & n.pers < 30 ---> n.s = 2
if n.pers > 30 & n.pers < 60 ---> n.s = 3
if n.pers > 60 & n.pers < 90 ---> n.s = 4
and so on
I don't know how if it's possible set up this cycle, anyway thanks.
I would like to set up a for loop that allows me to do the same calculations as the if loop in the figure.
for example
if n.pers < 10 ---> n.s = 1
if n.pers > 10 & n.pers < 30 ---> n.s = 2
if n.pers > 30 & n.pers < 60 ---> n.s = 3
if n.pers > 60 & n.pers < 90 ---> n.s = 4
and so on
I don't know how if it's possible set up this cycle, anyway thanks.
#5 Posted: 10/12/2021 1:57:13 PM
WroteHi I try to explain better what I want to calculate.
I would like to set up a for loop that allows me to do the same calculations as the if loop in the figure.
for example
if n.pers < 10 ---> n.s = 1
if n.pers > 10 & n.pers < 30 ---> n.s = 2
if n.pers > 30 & n.pers < 60 ---> n.s = 3
if n.pers > 60 & n.pers < 90 ---> n.s = 4
and so on
I don't know how if it's possible set up this cycle, anyway thanks.
You don't need an iteration.
Ceil() and cases() shall work for you.
Regards
1 users liked this post
Davide Carpi 10/12/2021 4:15:00 PM
#6 Posted: 10/12/2021 2:29:11 PM
Hi
I'm probably doing something wrong because, for exemple, with 40 or 70 it doesn't work.
I'm probably doing something wrong because, for exemple, with 40 or 70 it doesn't work.
#7 Posted: 10/12/2021 2:38:28 PM
#8 Posted: 10/12/2021 2:50:02 PM
The suggestion of Overlord is correct. You can also define a function and make different corresponding values calculate (using the Vectorize function)
number_seat.sm (6 KiB) downloaded 35 time(s).
sergio
number_seat.sm (6 KiB) downloaded 35 time(s).
sergio
#9 Posted: 10/12/2021 3:11:23 PM
Thank to all. you are great!
I used an old version. Now work correctly in my pc, too.
I used an old version. Now work correctly in my pc, too.
#10 Posted: 10/12/2021 3:41:15 PM
Page8 Social.sm (16 KiB) downloaded 29 time(s).
#11 Posted: 10/12/2021 5:42:31 PM
WrotePage8 Social.sm (16 KiB) downloaded 29 time(s).
Not related with OP's question.
#12 Posted: 10/12/2021 8:25:44 PM
1 Pages (12 items)
-
New Posts
-
No New Posts