Sabtu, 20 April 2013

Contoh kodingan Mencari Bilangan Ganjil dan Genap 1-50


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

/**
 *
 * @author Toshiba
 */
public class BilanganGenapdanGanjil {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        int i;
      System.out.print("Bilangan Ganjil = ");
      for (i = 1; i <= 50; i++) {
         if (i % 2 != 0) {
            System.out.print(" " + i);
         }
      }
      System.out.println("");
      System.out.print("Bilangan Genap = ");
      for (i = 1; i <= 50; i++) {
         if (i % 2 == 0) {
            System.out.print(" " + i);
         }
      }
      System.out.println("");
   }
}


Ini outputannya gan :D






Kalau Bingung, silahkan download projectnya disini gan :D      

THANKS, semoga bermanfaat :D
     
 

0 komentar:

Posting Komentar

 
Copyright © . Selamat Datang Di Blog Bagus Dermawan - Posts · Comments
Theme Template by BTDesigner · Powered by Blogger