Rabu, 01 Desember 2010

buat deret bilangan


kali ini kita akan buat deret bilangan


contoh : 666666555554444333221

public class deretbil {

int jb;
public static void main(String args[]){

String jumlah = "";

jumlah = JOptionPane.showInputDialog("Jumlah perulangan: ");

int jb = Integer.parseInt(jumlah);


for (int i=jb;i>=0;i--)
{
for (int k=0;k {
System.out.println(i);
}
}
}
}

HASILNYA :::::::



MAKA OUTPUTNYA


membuat segitiga terbalik dengan netbeans

kali ini mr mori mau menunjukan cara untuk membuat segitiga terbalik tapi dengan bintang contoh :



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

package UTS;

import javax.swing.JOptionPane;

/**
*
* @author moore
*/
public class segitigacoba {
public static void main (String args[])
{
int a,b,c;

String tinggi = "";

tinggi = JOptionPane.showInputDialog("masukkan panjang");

int v = Integer.parseInt(tinggi);

for(a=0;a<=v;a++) { for(b=0;b<=a;b++) { System.out.print(" "); } for(c=0;c>=(a-v);c--){
System.out.print("*");
}
for(c=0;c<(v-a);c++){ System.out.print("*"); } System.out.println(""); } } }