# Program BMI - Random Point

**URL:** <https://discourse.processing.org/t/program-bmi-random-point/10230>\
**Category:** Coding Questions\
**Created:** [April 13, 2019, 10:01am UTC](https://discourse.processing.org/t/program-bmi-random-point/10230 "2019-04-13T10:01:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![EverybodyEthan](https://avatars.discourse-cdn.com/v4/letter/e/db5fbb/32.png) [@EverybodyEthan](https://discourse.processing.org/u/EverybodyEthan)\
**Post date:** [April 13, 2019, 10:01am UTC](https://discourse.processing.org/t/program-bmi-random-point/10230/1 "2019-04-13T10:01:26Z")

</div>

Hey guys !

I’m new on the forum and I need help about my final project for exams.  
I’ve made over 90% of the job and I need few help to finish this. Since 2/3 weeks I’m searching for a way but it continues to be wrong 😕

So, when I execute my program, all is working like I want and a graphical window is appearing as normal when you can take a look to theoretical curves of the BMI.

On the first part, the user is questionned about his age, his weight and his size. He enters his answers then the windows is appearing perfectly.

Moreover, I’d like to create “the point of the user”, I mean, I’d like that a point appears according to his BMI and his age ; but I don’t find any way to do that

So I implore your help 😩

Hope to get answers !  
See ya !

PS : Sorry for my bad english, I’m from France and only seventeen years old 🙂

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 13, 2019, 10:27am UTC](https://discourse.processing.org/t/program-bmi-random-point/10230/2 "2019-04-13T10:27:24Z")

</div>

when age is a value on the x-axis (to the right)

and BMI on the y-axis (the higher the BMI the higher the point):

use map to say

```auto
float x = map(age,.....
float y = map(BMI, ....

ellipse(x,y,17,17);

```

Chrisir

---

<div class="post-metadata">

**Author:** ![EverybodyEthan](https://avatars.discourse-cdn.com/v4/letter/e/db5fbb/32.png) [@EverybodyEthan](https://discourse.processing.org/u/EverybodyEthan)\
**Post date:** [April 13, 2019, 10:55am UTC](https://discourse.processing.org/t/program-bmi-random-point/10230/3 "2019-04-13T10:55:11Z")

</div>

![Capture](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/f/f2a8b3eb1b35cd77aae752835618cb87d6bc3cfb.png)

It is in french but you might understand it as well.

The age must be between 10 and 18,

Moreover, I don’t know what to add after your “map”, I don’t know this function and I dont understand what they write on web 😕

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 13, 2019, 11:00am UTC](https://discourse.processing.org/t/program-bmi-random-point/10230/4 "2019-04-13T11:00:19Z")

</div>

**map is easy**

```auto
float result (e.g. x) = map(
Input value (the age),
range start 1, range end 1,
range start 2, range end 2);

```

let’s say your age is between 10 and 18: that’s _range 1_.

And you want to show it on the window which is the range from 0 to width - that’s _range 2_:  
Then map let’s you find the value you need on the 2nd range (x).

```auto
float x = map(age, 
10,18,
0,width);

```

map returns basically the percentage of the value (age) on the first range applied to the 2nd range.

Chrisir

---

<div class="post-metadata">

**Author:** ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)\
**Post date:** [April 13, 2019, 11:01am UTC](https://discourse.processing.org/t/program-bmi-random-point/10230/5 "2019-04-13T11:01:12Z")

</div>

Hi,

You need to map the value of your data to a location in the screen.

You know that age is between 10 and 18.  
Let’s say you want age 10 to be located at x = 10 and age 18 to be located at x = 90.

In that case you can find the position of every age using the map function as followed:  
map(age, 10, 18, 10, 100);

Here an example:

```auto
int ageMin = 10;
int ageMax = 18;
int xMin = 10;
int xMax = 90;

void setup() {
  size(100, 40);
  background(20);
  
  int age = 16;
  noStroke();
  fill(200);
  float xPos = map(age, ageMin, ageMax, xMin, xMax);
  ellipse(xPos, 20, 5, 5);
}

```

Try playing around with the value of age to see how it behaves.

---

<div class="post-metadata">

**Author:** ![EverybodyEthan](https://avatars.discourse-cdn.com/v4/letter/e/db5fbb/32.png) [@EverybodyEthan](https://discourse.processing.org/u/EverybodyEthan)\
**Post date:** [April 13, 2019, 12:09pm UTC](https://discourse.processing.org/t/program-bmi-random-point/10230/6 "2019-04-13T12:09:36Z")

</div>

Well, I understand everything you said !

But I’ve got this…

 ![essai](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/e/ea13627d706c10d65c613dc97d8ce1b7b28de518.png)

---

<div class="post-metadata">

**Author:** ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)\
**Post date:** [April 13, 2019, 12:11pm UTC](https://discourse.processing.org/t/program-bmi-random-point/10230/7 "2019-04-13T12:11:32Z")

</div>

You messed up the ellipse function. It should be x, y not y, 20 =)

---

<div class="post-metadata">

**Author:** ![EverybodyEthan](https://avatars.discourse-cdn.com/v4/letter/e/db5fbb/32.png) [@EverybodyEthan](https://discourse.processing.org/u/EverybodyEthan)\
**Post date:** [April 13, 2019, 12:20pm UTC](https://discourse.processing.org/t/program-bmi-random-point/10230/8 "2019-04-13T12:20:54Z")

</div>

GOD DAMN IT !

Guys, you’re the best, I love you so much \<3  
It worked perfectly as I expected ! \<3 \<3 \<3

Thanks so much !

I can’t know how to say thanks, I was looking for weeks and days !
