I'm currently making a program to calculate the value of pi, I believe using Simpson's Rule. I'm very new to the math and am still trying to get everything straight in my head, but I understand enough that I can start to work on some of the programming logistics of it. I'm basing a lot of this off of information from here
Anyways, right now I'm essentially trying to divide 1 into a given number of divisions. The user is actually putting in a number of data points that will be created by dividing 1 by a certain number, which is the number of data points minus 1. For example, in order to get 5 data points, you would have to divide 1 by 4. You'd get 0, .25, .5, .75, and 1 as data points. I'm storing these data points in an array. I think I will create a separate value for the number of divisions as to avoid even more math when assigning the values of the data points to variables in the array. I'm getting these values through a for loop. The basic idea is something like this:
Now this would be all fine and dandy if it weren't for the fact that I want to use a float, not an int. I've never really worked with floats, but I'm pretty sure you have to tag an "f" on to the end of the number you are assigning it. I guess my main question is this: how do you assign a float type variable a value based off of another variable? I feel kind of stupid for asking it, but I guess I've just never really worked with floating point numbers in Java '~'. Thanks in advance!