[code] Java For

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

package FOR;

/**
 *
 * @author FIQI
 */
import java.util.Scanner;
public class PernyataanFOR {
public static void main(String[]args){

    Scanner sc = new Scanner(System.in);

    System.out.print("Masukkan nilai awal : ");
    int n1= sc.nextInt();
  
    System.out.print("Masukkan nilai akhir : ");
    int n2= sc.nextInt();
    for(int i=n1; i<n2; i++)

    {
      if (i%2==1)//untuk menampilkan ganjil dan genap
          System.out.println(i);//System.out.println(i*-1); untuk menghasilkan output dengan min
                                //System.out.println(i+"*"); untuk menghasilkan 1* dst

      else
          System.out.println(i);
    }
  }
}

0 komentar:

Posting Komentar

: Ayoo sharingg.. :D

Related Posts Plugin for WordPress, Blogger...

Sponsor

Banner

Ayo kita tukar - tukaran banner : my code banner :
ImagineWorld
and my friend :