Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Getallenrij {
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- int[] a = {1,2,3,4};
- drukAf(newArray(toArray(a)));
- }
- static public ArrayList<Integer> toArray (int[] a){
- ArrayList<Integer> lijst = new ArrayList<Integer>();
- for (int i = 0; i<lijst.size(); i++){
- Integer z = a[i];
- lijst.add(z);
- }
- return lijst;
- }
- static public ArrayList<Double> newArray (ArrayList<Integer> a){
- ArrayList<Double> lijst = new ArrayList<Double>();
- for (int i = 0; i<a.size(); i++){
- if (i==0){
- Double z = (0.25*(2*a.get(i) + a.get(i+1)));
- lijst.add(z);
- }
- else if (i == lijst.size()-1){
- Double z = 0.25*(a.get(i-1)+2*a.get(i));
- lijst.add(z);
- }
- else{
- Double z = 0.25*(a.get(i-1)+2*a.get(i) + a.get(i+1));
- lijst.add(z);
- }
- }
- return lijst;
- }
- static public void drukAf (ArrayList<Double> a){
- for (int i = 0; i<a.size(); i++){
- System.out.println(Double.valueOf(a.get(i)));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement