Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Simple question, how do I add double elements to my 1D array (java)?

$
0
0
My assignment was to divide 2 pi by 100 and take the cos of each value and put them into an array, I don't know why I am having errors but when i run the program i get weird symbols.
public class Array1D {

	public static void main(String[] args) {
		double [] array = new double[101];
		
		
		for(int i=0; i<100;i++){
			double a = (Math.PI/100.0)*i;
			double b = Math.cos(a);
			
			array[i]=b;
			System.out.println(array);
		}

}
}


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>