Minggu, 27 Februari 2011

Pesan di awal start up



Tambahkan tulisan berikut pada file autoexec.bat :

    Echo off Cls Echo Komputer ini milik Rossi Echo. Echo Jadi jangan diobok-obok ya... Echo. For %%C in(A B C D E F G H I J K L) do Dir C:\Windows >Null Echo. Echo Kalau macem-macem, AWAS..!!!

Sabtu, 12 Februari 2011

belajar java

R_Total.java
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import java.util.Scanner;
 
class R_Total
{
  public static void main (String[] args)
  {
    double r1, r2, r3, r_total_seri, r_total_pararel;
 
    Scanner scan = new Scanner(System.in );
 
    System.out.println("Masukkan nilai R1:");
    r1 = scan.nextDouble();
 
    System.out.println("Masukkan nilai R2:");
    r2 = scan.nextDouble();
 
    System.out.println("Masukkan nilai R3:");
    r3 = scan.nextDouble();
 
    r_total_seri    = r1 + r2 + r3;
    r_total_pararel = ((r1*r2*r3) / (r2*r3+r1*r3+r1*r2));
 
    System.out.println("Total nilai R pada Rangkaian Seri R1, R2, R3 = " + r_total_seri );
    System.out.println("Total nilai R pada Rangkaian Pararel R1, R2, R3 = " + r_total_pararel );
  }
}
Kalau mau copy-paste dan dikumpulkan sebagai tugas, tolong modifikasi terlebih dahulu sesuai selera/kemampuan Anda. Yang paling penting adalah memahaminya dulu.

Bedah Code

1
import java.util.Scanner;
Kode ini digunakan untuk meload library Scanner. Library ini memiliki fungsi salah satunya untuk fungsi menerima input dari user (input dari keyboard).
1
double r1, r2, r3, r_total_seri, r_total_pararel;
Kode ini digunakan untuk mendeklarasikan variabel-variabel (beserta tipe datanya) yang dibutuhkan.
double = tipe data yang digunakan untuk r1, r2, r3, r_total_seri, r_total_pararel;
r1 = nilai R1
r2 = nilai R2
r3 = nilai R3
r_total_seri = variabel yang akan menampung hasil operasi penghitungan R Total pada rangkaian seri.
r_total_pararel = variabel yang akan menampung hasil operasi penghitungan R Total pada rangkaian pararel.
1
Scanner scan = new Scanner(System.in );
Untuk menjalankan objek Scanner (input) dengan nama alias scan.
1
System.out.println("Masukkan nilai R1:");
Perintah ini akan mencetak baris tulisan “Masukkan nilai R :” pada program.
1
r1 = scan.nextDouble()
Perintah ini akan meminta input dari user ketika program dijalankan. Input tersebut nantinya akan dimasukkan ke dalam variabel r1. Tapi ingat, tipe data r1 adalah double, sehingga data yang bisa diinputkan adalah bilangan double. Fungsi scan.nextDouble() juga perlu diperhatikan di sini. Kalau tipe datanya bukan Double, berarti juga harus disesuaikan.
Begitu juga dengan perintah-perintah berikutnya (r1, r2, r3)
1
2
r_total_seri    = r1 + r2 + r3;
r_total_pararel = ((r1*r2*r3) / (r2*r3+r1*r3+r1*r2));
Kode ini untuk melakukan operasi perhitungan mencari nilai R Total dalam rangkaian seri dan R Total dalam rangkaian pararel, kemudian hasil operasi hitungan tersebut, dimasukkan ke dalam variabel-variabel yang sudah kita deklrasikan di awal.
Operasi perhitungan ini adalah operasi matematika biasa (ingat rumus Fisika juga). Algoritmanya juga dibuat yang sesuai dengan rumus.
1
2
System.out.println("Total nilai R pada Rangkaian Seri R1, R2, R3 = " + r_total_seri );
System.out.println("Total nilai R pada Rangkaian Pararel R1, R2, R3 = " + r_total_pararel );
Kode ini untuk mencetak output nilai variabel r_total_seri dan r_total_pararel. Variabel tersebut berisi hasil operasi perhitungan matematika tadi.

Compile dan Run

Compile dengan perintah javac R_Total.java
Run dengan perintah java R_Total
Hasil eksekusi program:
1
2
3
4
5
6
7
8
Masukkan nilai R1:
3
Masukkan nilai R2:
4
Masukkan nilai R3:
12
Total nilai R pada Rangkaian Seri R1, R2, R3 = 19.0
Total nilai R pada Rangkaian Pararel R1, R2, R3 = 1.5

Bangun ruang inputan dari keyboard dengan java

19 Februari 2010
Sekarang kita akan mencoba membuat program kita lebih interaktif dengan menggunakan input dari keyboard, Sama seperti di fungsin cin dalam bahasa C++
Kita akan mempelajari dua cara memberikan input
1. Menggunakan kelas BufferedReader
2.Melalui GUI (Graphical User Interface) dengan menggunakan kelas JOptionPane.

Menggunakan Bufferedreader Untuk Mendapatkan Input
Pada bagian ini, kita akan menggunakan kelas BufferedReader yang berada di java.io package untuk mendapatkan input dari keyboard.

Berikut ini adalah langkah-langkah yang diperlukan untuk mendapatkan input dari keyboard:
a. Tambahkan di bagian paling atas code anda: import java.io.*;
b. Tambahkan statement ini:
BufferedReader dataIn = new BufferedReader(new InputStreamReader( System.in) );
c. Deklarasikan variabel String temporer untuk mendapatkan input, dan gunakan fungsi readLine() untuk mendapatkan input dari keyboard. Anda harus mengetikkannya di dalam blok try-catch:
try{
String temp = dataIn.readLine();
}
catch( IOException e ){
System.out.println("Error in getting input");
}


Contoh Program:
import java.io.*;
public class DemoInputString {
public static void main(String[] args) throws IOException {
System.out.print("Masukkan nama Anda: ");
String nama;
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
nama = br.readLine();
System.out.println("Halo" + nama + ", sudahkah mengerti Java?");
}
}


Contoh Program 2:

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class GetInputFromKeyboard
{
public static void main( String[] args ){
BufferedReader dataIn = new BufferedReader(new InputStreamReader( System.in) );
String name = "";
System.out.print("Please Enter Your Name:");
try{
name = dataIn.readLine();
}catch( IOException e ){
System.out.println("Error!");
}
System.out.println("Hello " + name +"!");
}
}


Penjelasan Program 2
Statemen:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

Menjelaskan bahwa kita akan menggunakan kelas BufferedReader, InputStreamReader dan IOException yang berada di java.io package.
Java Application Programming Interface (API) sudah berisi ratusan kelas yang bisa digunakan untuk program anda.
Kelas-kelas tersebut dikumpulkan ke dalam packages.


Dua statemen selanjutnya:
public class GetInputFromKeyboard
{
public static void main( String[] args ){

Statement ini menyatakan bahwa kita mendeklarasikan sebuah class bernama GetInputFromKeyboard dan kita mendeklarasikan main method.

Pada Statemen
BufferedReader dataIn = new BufferedReader(new InputStreamReader( System.in) );
kita mendeklarasikan sebuah variabel bernama dataIn dengan tipe kelas BufferedReader.
System.in di gunakan untuk membaca, tapi sangat lambat karena di baca satu persatu sehingga digunkan buffer (penyangga)
Buffer tidak bisa membaca langsung dari keyboard, yang bisa hanya system.in, maka di gunakanlah stream(inputstreamreader)


String name = ""; ;
mendeklarasikan variabel String dengan identifier name
Statement diatas merupakan tempat untuk menyimpan input dari user. Variabel name diinisialisasi sebagai String kosong "".


System.out.print("Please Enter Your Name:");
Baris berikutnya adalah memberikan output string pada layar menanyakan nama user.

Blok di bawah ini merupakan blok try-catch blok
try{
name = dataIn.readLine();
}catch( IOException e ){
System.out.println("Error!");
}
System.out.println("Hello " + name +"!");
}

Pada baris ini menjelaskan bahwa kemungkinan terjadi error pada statement
name = dataIn.readLine();
akan ditangkap .
anda perlu menambahkan kode ini untuk menggunakan readLine() method dari BufferedReader untuk mendapatkan input dari user

Wireless Internet Terminology - Confusion Or Clarity?

Wireless Internet Terminology, like many things in life, especially those that have anything to do with computers is filled with terminology. But like most things, once you learn a few of the basic terms, understanding will come quickly. So don't be confused get informed and to help clarify, I've put together a basic wireless "internet-to-english" guide to help you along.

IEEE - The Institute of Electrical and Electronics Engineers
The IEEE is in charge of the wireless networking standard, as well as many other computer-related standards - including the Ethernet standard. They ensure that computer equipment made by different manufacturers can work together.

PCMCIA - Personal Computer Memory Card International Association
Simply another standard for how to plug credit card size devices into a laptop computer to boost it's capabilities. It's been suggested by some that it should stand for "People Can't Memorize Computer Industry Acronyms". PCMCIA is a great way of adding wireless networking to your laptop as easily as inserting a disk.

PCI - Peripheral Component Interconnect
Used to install devices like graphics cards and network devices inside your computer. You would be using a PCI, if you wanted to install a wireless card inside your computer.

802.11
Set by the IEEE, it's the current wireless networking standard. It helps ensure that wireless devices can communicate with one another or in other words - they are interoperable.

Interoperable
Simply means that two different pieces of equipment have the ability to speak to each other or another way to put it - they are compatible. They can use them together because they were designed using the same standards. Because of the IEEE and the principle of interoperability, all wireless equipment you purchase should be compatible.

Driver
Not a piece of golf equipment but computer software that informs a computer how to talk to devices that plug into it. Most wireless networking drivers come on a CD-ROM. You then download the drivers from the CD onto your computer.

Ethernet
Currently, the most common way of connecting to a LAN or Local Area Network. Most wires connected to your computer today are ethernet and if you have a cable internet connection an ethernet wire is in all likely-hood, what is being used to connect to your modem.

USB - Universal Serial Bus
A port used for connecting all sorts of devices to a computer, including keyboards, a mouse, printers, external hard-drives and basically anything else you can think of. If you don't have a laptop or want to open up your computer you can get a USB wireless device.

WEP - Wired Equivalent Privacy
No longer used because in 2001 it was found to have security issues. As a result, it is now the old standard for encrypting wireless networks.

WPA - WiFi Protected Access
The new standard for encrypting wireless networks. An upgrade of WEP to fix security issues. To avoid becoming vulnerable, a WPA encrypted network changes encryption methods often. In addition, if an attack is detected, it has the ability to shut itself down for thirty seconds.

PAN - Personal Area Network
A network of devices connected together in one small area. A simple example of a PAN would be your computer, USB keyboard and mouse. Using a technology called Bluetooth, a PAN can be wireless.

LAN - Local Area Network
Briefly mentioned above, LAN is a computer network that... generally speaking is confined to one building, such as a home or office. A wireless LAN is also known as a WLAN.

MAN - Metropolitan Area Network
A network that covers a larger area, like a city or town. They are expensive but a wireless MAN has the capacity to spread Internet access across a wide area. Many college universities set-up a MAN to connect the entire campus.

WAN - Wide Area Network
A network that covers or connects to more than one physical site. A simple example would be a business that has locations in different cities, states or countries and they need them each location connected on the same network. The Internet itself is a WAN... the biggest WAN in the world.

Mbps - Megabits Per Second
Not to be confused with MBps, megabytes per second. Mbps is measurement of connection speed. There are eight megabits in a megabyte.

GHz - Gigahertz
One gigahertz is one billion cycles per second... it's a measurement of frequency. If the term sounds familiar it's probably because it's also used to measure the processing speed of the CPU on your computer, which is also measured in gigahertz.

Linux
A popular and growing alternative operating system to Windows. Linux is a less bulky, more efficient operating system in many ways than Windows and not to mention - it's free. Many servers run Linux for this reason. Computers running Linux can run many programs and connect to the Internet without needing Windows. Many wireless devices run Linux or are compatible with it.