Monday 8 April 2013

Mencari Kelipatan 3 dan 7 yang sama


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pbo1;

/**
 *
 * @author acer
 */
public class Pbo1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        int a=0;
        System.out.print("Bilangan kelipatan 3 dan kelipatan 7 antara 10 s/d 75 adalah ");
        for (int i = 10; i<75; i++){
            if(i % 7 ==0 && i % 3 ==0 ){
                System.out.print(i+",");
                a=a+i;
            }
        }
        System.out.println("\nTotal bilangan adalah "+a);
    }
}


0 komentar:

Post a Comment

Note: only a member of this blog may post a comment.