Membuat program sederhana bilangan fibonacci sebanyak 20 bilangan

Berikut textnya:

01 class Fibonaccidevioktaviani {
02     public static void main(String[] args) {
03         int A=1;
04         int B=1;
05         int n=20;
06         System.out.println(A+" ");
07         for (int i=1;i          System.out.println(B+" ");
08             B=A+B;
09             A=B-A;
10
11         }
12         System.out.println("");
13         System.out.println("devioktaviani");
14     }
15 }

Dan jika berhasil maka cmd akan menampilkan

Membuat program sederhana menghitung luas Lingkaran dan keliling ligkaran

 

01 import java.io.*;
02
03 public class RumusLingkaran{
04
05     public static void main(String args[]){
06
07         try{
08
09             float nilair;
10
11             float kel;
12
13             float luas;
14
15             float pi = 3.14f;
16
17             System.out.println("Menghitung Luas Dan Keliling Lingkaran");
18
19             System.out.print("Masukan Jari Jari R:");
20
21             BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
22
23             nilair = Float.parseFloat(r.readLine());
24
25             kel = 2 * pi * nilair;
26
27             luas = pi * (nilair * nilair);
28
29             System.out.println("Luas Lingkaran : " + luas);
30
31             System.out.println("Keliling Lingkaran : " + kel);
32
33         }
34
35         catch (IOException ie){
36
37             System.out.println(ie.getMessage());
38
39         }
40
41     }
42
43 }

dan akan muncul seperti ini
saya menggunakan jari jari nya 7.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s