week 1
Java programing terbagi menjadi 3 :- J2SE (standart edition)
- J2ME (java mobile edition)
- J2EE (Application HP)
System.out.print
- System.out.print adalah untuk menampilkan teks di layar
- contoh: System.out.print
- System.out.print("welcome to Netbeans");
- Contoh: System.out.println
- System.out.println("line1");
JOptionPane.showInputDialog
- JoptionPane J=new JOptionPane ();
- String julukan=JoptionPane.showInputDialog("panggilan")
- System.out.println(julukan)
- Char = 1 huruf "a"
- String = lebih dari 1 huruf "budi"
- Int = anka bilangan bulat [(-3500) => (+3500)]
- Long = angka bilangan bulat [Lebih dari (+3500)]
- Float = bilangan pecahan / desimal [(-3500) => (+3500)]
- Double = bilangan pecahan / desimal [lebih dari (+3500)]
week 2
perbedaan Notped++ dengan NetBeans adalah perbedaan warna saja
Noteped++
My computer-> klik kanan(properties)-> Advanced(Environment Variables)-> new name(PATH) value (C:\Program File\java\jdk1.6.0_11\bin)-> OK
masuk program noteped=
co 1:
public class Main
{
public static void main(String[] args)
{
// TODO code application logic here
int cel=32;
float fah= (float)(cel*1.8)+32;
float rea= (float)(0.8*cel);
System.out.println(cel + "total " +fah +" Farenheit" );
System.out.println(cel + "total " +rea +" reamut" );
}
}
co 2:
import java.util.Scanner;
public class Prog1
{
public static void main(String[] args)
{
Scanner s=new Scanner(System.in);
System.out.println("masukkan total uang : ");
int totalUang=s.nextInt();
int diskon1= (int)(totalUang*0.06);
int diskon2= (int) (totalUang*0.08);
int diskon3= (int) (totalUang*0.1);
System.out.println("diskon 1= " +diskon1);
System.out.println("diskon 2= " +diskon2);
System.out.println("diskon 3= " +diskon3);
}
}
week 3
persamaan linirt berikut:
a1x + b1y = c1
a2x + b2 = c2
dapat d selesaikan dengan rumus :
x = c1.b2 - c2.b1 y = a1.c2 - a2.c1
a1.b2 - a2.b1 a1.b2 - a2.b1
contoh di notepad:
import java.util.Scanner;
public class HitungLinier
{
public static void main(String[] args)
{
Scanner s=new Scanner(System.in);
System.out.println("masukan A1..?");
int a1 = s.nextInt();
System.out.println("masukan b1..?");
int b1 = s.nextInt();
System.out.println("masukan C1..?");
int c1 = s.nextInt();
System.out.println("masukan A2..?");
int a2 = s.nextInt();
System.out.println("masukan B2..?");
int b2 = s.nextInt();
System.out.println("masukan C2..?");
int c2 = s.nextInt();
int x= (c1*b2-c2*b1/a1*b2-a2*b1);
int y= (a1*c2-a2*c1/a1*b2-a2*b1);
System.out.println("hasil x adalah" +x);
System.out.println("hasil y adalah" +y);
}
}
buatlah program untuk mengisikan nama, alamat, telepon, dan, tanggal lahir seseorang kemudian buatlah sebuah cerita dengan memakai data-data yg ada:
import java.util.Scanner;
public class Nama
{
public static void main(String[] args)
{
Scanner s=new Scanner(System.in);
System.out.println("masukan nama anda..");
String nama = s.next();
System.out.println("masukan tanggal lahir anda..");
String tgl = s.next();
System.out.println("masukan alamat rumah anda..");
String alm = s.next();
System.out.println("masukan telpon anda..");
String tlp = s.next();
System.out.println("nama anda " +nama + " tgl lahir " +tgl + " rumah di " +alm + " telepon yg dapat di hubungi " +tlp + "hallo");
}
Looping.....
Looping1
import java.util.Scanner;
public class Looping
{
public static void main (String [] args)
{
Scanner s= new Scanner(System.in);
System.out.print("Masukan n: ");
int n=s.nextInt();
for(int i=1; i<=n; i++)
{
for(int j=1; j<=n-(i-1); j++)
{
System.out.print("*");
}
System.out.print("\n");
}
for (int a=1; a<=n-1; a++)
{
for (int b=n-a; b<=n; b++)
{
System.out.print("*");
}
System.out.print("\n");
}
}
}
Looping2
import java.util.Scanner;
public class Looping2
{
public static void main (String [] args)
{
Scanner s= new Scanner(System.in);
System.out.print("Masukan n: ");
int n=s.nextInt();
for(int i=1; i<=n; i++)
{
for(int j=1; j<=n-(i-1); j++)
{
System.out.print(" ");
}
for(int k=1; k<=(i*2)-1; k++)
{
if(i==n && k==n)
{
System.out.print("+");
}
else
{
System.out.print("*");
}
}
System.out.print("\n");
}
for(int a=1; a<=n; a++)
{
for(int b=n-a; b<=n; b++)
{
System.out.print(" ");
}
for (int c=(2*a)-1; c<=2*n-3; c++)
{
System.out.print("*");
}
System.out.print("\n");
}
}
}
Looping 3
import java.util.Scanner;
public class Looping3
{
public static void main(String [] args)
{
Scanner s=new Scanner(System.in);
System.out.print("Masukan Angka: ");
int angka=s.nextInt();
int i=1;
do
{
angka=angka/10;
i++;
}
while (angka>0);
System.out.println(i-1);
}
}
Tidak ada komentar:
Posting Komentar