Latihan Java
Latihan Paradigma pemerograman
Arip – 2103210039
contoh program java
Latihan :
1.
Jawaban
latihan no 1 :
public class Tugas1 {
/**
* @param args
*/
public static void main(String[] args)
{
// TODO Auto-generated
method stub
byte B =1 ;
int I=10;
long L=12345;
char C='a';
String S="s";
Float F=0.1f;
double D=100;
boolean Bo=true;
System.out.println(B);
System.out.println(I);
System.out.println(L);
System.out.println(C);
System.out.println(S);
System.out.println(F);
System.out.println(D);
System.out.println(Bo);
}
}
2.
Jawaaban latihan no 2 :
public class Tugas2 {
/**
* @param args
*/
public static void main(String[] args)
{
// TODO Auto-generated
method stub
float phi=3.14f;
double r=2;
double L;
L=phi*(r*r);
System.out.println("Luas=Phi * r
* r");
System.out.println("phi = "+phi);
System.out.println("r = "+r);
System.out.println("Luas = "+phi+ " * "+r+" * "+r);
System.out.println("Luasnya =
"+L);
}
}
Comments
Post a Comment