Linggo, Pebrero 12, 2012

basic act 7 : array . carries



package javaapplication4;


public class JavaApplication4 {


    public static void main(String[] args) {
      


        int val[] = {1, 2, 3, 4, 5, 6, 7};
        int pe[] = {1, 2, 3, 4, 5, 6, 7};
        int x = 0;
        int y =0;
        for (int i = 0; i < val.length; i++) {
            x=0;
            x += val[i] +pe[i];
            if (x >= 10){
                y += 1;}
            
        }
    if (y == 0){
                System.out.println("no carries");  
    }
      else
            System.out.println(y + "carries");
        
    }
}

Walang komento:

Mag-post ng isang Komento