Results 1 to 2 of 2
- 03-05-2013, 07:42 PM #1
Member
- Join Date
- Jan 2013
- Posts
- 5
- Rep Power
- 0
How to: Create a range of desired variables (two decimals) into an array
Hi everyone,
I'm curious how I can create a range of desired variables ranging from (-1.00 all the way to 1.00) @ 0.01 increments.
I will want to output this in table format as the first column. There will be 4 columns btw
1st column = the variable [two decimals btw -1.00 and 1.00]
2nd column = math.sin(x) of each
3rd column = my personal sin function
4th column = math.abs(difference between them)
I'm calling my other personally created sin(x) method and attemping to output in table format.Java Code:public class TaylorSin { public static void main(String[] args) { for (double lB = -100, lB <= 100,lB++) lB.log(x/100); double[] x = lB; double ActualFormula = math.sin(x); double MyFormula = sin(x); double Absolute = math.abs(ActualFormula - MyFormula); System.out.format("%3d%10d%10d%4d", double x, ActualFormula, MyFormula, Absolute);
Let me know, because I'm very confused.Last edited by mcgillstudent; 03-05-2013 at 07:47 PM.
- 03-05-2013, 08:16 PM #2
Senior Member
- Join Date
- Jan 2013
- Location
- United States
- Posts
- 703
- Rep Power
- 1
Re: How to: Create a range of desired variables (two decimals) into an array
Your for loop only has a single statement in it. And it doesn't do anything unless you are changing something in IB.log(). But even then, x is undefined.
To increment your value by .01 in your for loop just use IB = IB + .01 (or shorthand IB += .01)
Regards,
JimThe Java™ Tutorial
YAT -- Yet Another Typo
Similar Threads
-
apply an array to variables
By Stamoulohta in forum New To JavaReplies: 5Last Post: 03-16-2011, 12:27 PM -
Array index out of range: 1 HELP!
By TheBreadCat in forum New To JavaReplies: 2Last Post: 02-17-2011, 08:50 PM -
Range within an Array
By End in forum New To JavaReplies: 6Last Post: 04-18-2009, 06:53 PM -
Writing integer pixel array(Range:0-255) into .txt file
By Mazharul in forum Java 2DReplies: 3Last Post: 08-24-2008, 01:51 PM -
how to create environment variables
By elizabeth in forum Advanced JavaReplies: 4Last Post: 08-02-2007, 04:53 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks