//10101056
public class latihan{
public static void main(String[] args){
String a = "I DEWA GDE AGUNG WIRA ADNYANAN";
int b = 10101056;
String c = "3,09";
System.out.println("Nama: " + a);
System.out.println("NIM: " + b);
System.out.println("IP: " + c);
}
}
==========================================================================
//10101056
public class latihan2{
public static void main(String[] args){
int r = 9;
int t = 13;
double pi = 3.14;
double Lalas = pi*r*r;
double Lselimut = 2*pi*r*t;
double L = (2*Lalas)+Lselimut;
System.out.println("Luas Silinder= " + L);
}
}
==============================================================================
//10101056
public class latihan3{
public static void main(String[] args){
double quis = 70.5;
double tugas = 80.5;
double uts = 60;
double uas = 90.5;
double Tquis = (10*quis)/100;
double Ttugas = (10*tugas)/100;
double Tuts = (30*uts)/100;
double Tuas = (50*uas)/100;
double NA = Tquis+Ttugas+Tuts+Tuas;
System.out.println("Nilai Quis= " + quis);
System.out.println("Nilai Tugas= " + tugas);
System.out.println("Nilai UTS= " + uts);
System.out.println("Nilai UAS= " + uas);
System.out.println("Jadi nilai akhir adalah= " + NA);
}
}
==========================================================================
public class array{
public static void main (String[] args){
int nilai[] = {1,2,3,4,5,6};
for (int i=0;i<6;i++){
System.out.println(nilai[i]);
}
}
}
==========================================================================
public class array2D{
public static void main (String[] args){
int nilai[][] = {{1,2,3,4,5,6},
{6,7,8,9,10},
{11,12,13,14,15,16}};
for (int i=0;i<6;i++){
for (int j=0;j<i;j++)
System.out.println(nilai[i][j]+" ");
System.out.println(" ");
}
}
}
===========================================================================
import java.util.Scanner;
public class array2D {
public static void main (String[] args)
{ Scanner input=new Scanner(System.in);
String [][] kata={
{"one","satu"},{"cow","sapi"},{"run","lari"},{"red","merah"},{"man","orang"}
};
String katadicari;
System.out.print("Kata Yang Di Cari = ");
katadicari=input.nextLine();
int i,k;k=-1;
for (i=0;i<5;i++)
{
if(kata[i][0].equals(katadicari))
{
k=i;
}
}
if (k==-1)
{System.out.println ("kata yang di cari tidak ditemukan");
}
else
{
System.out.println("terjemahan = "+kata [k][1]);
}
}
===========================================================================
import java.util.Scanner;
public class array {
public static void main(String[] args){
int[][] Mat1 = new int[3][3];
Scanner s = new Scanner(System.in);
System.out.print("\n-Input Matriks-\n");
InputMatriks(Mat1);
System.out.print("\n-Matriks-\n");
tampilMatriks(Mat1);
System.out.print("\n Masukan variabel yang anda cari : "); int cari = s.nextInt();
cariMatriks(Mat1,cari);
}
public static void InputMatriks(int[][] matriks1){
Scanner scansod = new Scanner(System.in);
for(int i=0; i<matriks1.length;i++){
for(int j=0; j<matriks1[i].length;j++){
System.out.print(" Masukan elemen matriks A["+(i+1)+"]["+(j+1)+"]:");
matriks1[i][j]=scansod.nextInt();
}
}
}
public static void tampilMatriks(int[][] matriks){
for(int i=0; i<matriks.length;i++){
for(int j=0; j<matriks[0].length;j++){
System.out.print(" "+matriks[i][j]);
}System.out.print("\n");
}
}
public static void cariMatriks(int[][] matriks, int cari){
for(int i=0; i<matriks.length;i++){
for(int j=0; j<matriks[0].length-1;j++){
if(matriks[i][j]==cari){
System.out.print(" Variabel "+cari+" ada di matriks dengan baris "+(i+1)+" kolom "+(j+1)+"\n\n");
}
}
}
}
}
==========================================================================
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
String nama[] = new String[7];
Scanner input = new Scanner (System.in);
for (int i=0;i<6;i++){
System.out.println("inputkan ke "+ i +" = ");
nama[i] = input.next();
}
for(int i=0;i<6;i++){
System.out.println("inputkan ke "+ i +" = "+nama[i]);
}
}
}
===========================================================================
public class Main {
public static void main(String[] args) {
int a = 2;
int b = 15;
while (a<=b)
{
if (a % 2 == 1)
{
System.out.println(a++);
}
a++;
}
}
}
===========================================================================
package klasifikasinilai;
import javax.swing.JOptionPane;
/**
*
* @author Admin
*/
public class klasifikasinilai {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int quiz,uts,uas;
double na;
String grade, nilaistr;
JOptionPane.showMessageDialog(null, "Program Grade pada nilai");
//Masukkan nilai quiz
nilaistr = JOptionPane.showInputDialog(null,"Masukkan Nilai Quiz:");
quiz = Integer.parseInt(nilaistr);
//Masukkan nilai uts
nilaistr = JOptionPane.showInputDialog(null,"Masukkan Nilai UTS:");
uts = Integer.parseInt(nilaistr);
//masukkan nilai uas
nilaistr = JOptionPane.showInputDialog(null,"Masukkan Nilai UAS:");
uas = Integer.parseInt(nilaistr);
//Hitung nilai akhir
na = 0.2*quiz + 0.3*uts + 0.5*uas;
//kondisional grade
if (na > 80)
grade = "A";
else if ( na > 70)
grade = "B";
else if (na >55)
grade = "C";
else if (na > 40)
grade = "D";
else
grade ="E";
//Menampilkan Hasil
JOptionPane.showMessageDialog(null, "Nilai akhir = " + na + "grade: " + grade);
// TODO code application logic here
}
}
==========================================================================
class krucut{
double r;
double tinggi;
double vol;
double hitvol(double j,double t){
r = j;
tinggi = t;
vol = (Math.PI * r*r*tinggi)/3;
return vol;
}
}
public class luaskrucut{
public static void main(String[] args){
krucut k = new krucut();
k.r = 9;
k.tinggi = 12;
double volume = (3.14*k.r*k.r*k.tinggi)/3;
System.out.println(" Volume krucut = " +volume);
}
}
===========================================================================
class krucut{
double r;
double t;
public static void main(String[] args){
krucut k = new krucut();
k.r = 9;
k.t = 12;
double volume = (3.14*k.r*k.r*k.t)/3;
System.out.println(" Volume krucut = " +volume);
}
}
==============================================================================
class kotak{
double panjang;
double lebar;
double tinggi;
void cetakVolume(){
System.out.println("Volume Kotak= " + (panjang*lebar*tinggi));
}
}
public class luaskotak{
public static void main(String[] args){
kotak k = new kotak();
k.panjang = 6;
k.lebar = 9;
k.tinggi = 12;
k.cetakVolume();
}
}
============================================================================
import java.util.Scanner;
class menu{
double alas,panjang,lebar,tinggi,hasil;
double segitiga(double alas, double lebar, double tinggi){
alas = a;
tinggi = t;
hasil = (a*t)*0.5;
return hasil;
}
double persegipanjang(double panjang, double lebar){
panjang = p;
lebar = l;
hasil = p*l;
return hasil;
}
public static void main(String[] args){
menu isi = new menu();
System.out.println("");
System.out.println("===========================================");
System.out.println("Silahkan Pilih Menu untuk Menghitung Tabung");
System.out.println("===========================================");
System.out.println(" |1. Segitiga | ");
System.out.println(" |2. Persegi panjang| ");
System.out.println(" |0. Keluar | ");
System.out.println("===========================================");
System.out.print("Masukkan Pilihan Anda : ");
Scanner pilih = new Scanner(System.in);
int pilihan = pilih.nextInt();
if(pilihan == 1)
{
System.out.print("Masukan bilangan 1 : ");
double a = pilih.nextDouble();
System.out.print("Masukan bilangan 2 : ");
double b = pilih.nextDouble();
System.out.println("===========================================");
System.out.println("Hasil Penjumlahan : " +isi.segitiga );
System.out.println("");
}
if(pilihan == 2)
{
System.out.print("Masukan bilangan 1 : ");
double a = pilih.nextDouble();
System.out.print("Masukan bilangan 2 : ");
double b = pilih.nextDouble();
System.out.println("===========================================");
System.out.println("Hasil Perkalian : "+isi.persegipanjang);
System.out.println("");
}
if(pilihan == 0)
{
System.out.println("Terima Kasih");
System.out.println("**created by Radhitya**");
System.exit(0);
}
}
}
============================================================================
class Mobil {
String warna; //boleh terdiri dari banyak kelas
int tahun; //hanya ada satu void main //deklarasi nama kelas bebas
String merk;
}
class mobiljenazah{
class mobilsedan{
public static void main(String[] args){
Mobil mobil1 = new Mobil(); //cara membuat objek
mobil1.warna = "Hitam";
mobil1.tahun = 2004;
mobil1.merk = "Honda Jazz";
Mobil mobilJ = new Mobil();
mobilJ.warna = "Putih";
mobilJ.tahun = 2000;
mobilJ.merk = "Toyota Kijang";
System.out.println("Warnanya " + mobil1.warna);
System.out.println("Tahun= " + mobil1.tahun);
System.out.println("Merk= " + mobil1.merk);
System.out.println("Warnanya " + mobilJ.warna);
System.out.println("Tahun= " + mobilJ.tahun);
System.out.println("Merk= " + mobilJ.merk);
}
}
}
===========================================================================
public class latihan{
public static void main(String[] args){
String a = "I DEWA GDE AGUNG WIRA ADNYANAN";
int b = 10101056;
String c = "3,09";
System.out.println("Nama: " + a);
System.out.println("NIM: " + b);
System.out.println("IP: " + c);
}
}
==========================================================================
//10101056
public class latihan2{
public static void main(String[] args){
int r = 9;
int t = 13;
double pi = 3.14;
double Lalas = pi*r*r;
double Lselimut = 2*pi*r*t;
double L = (2*Lalas)+Lselimut;
System.out.println("Luas Silinder= " + L);
}
}
==============================================================================
//10101056
public class latihan3{
public static void main(String[] args){
double quis = 70.5;
double tugas = 80.5;
double uts = 60;
double uas = 90.5;
double Tquis = (10*quis)/100;
double Ttugas = (10*tugas)/100;
double Tuts = (30*uts)/100;
double Tuas = (50*uas)/100;
double NA = Tquis+Ttugas+Tuts+Tuas;
System.out.println("Nilai Quis= " + quis);
System.out.println("Nilai Tugas= " + tugas);
System.out.println("Nilai UTS= " + uts);
System.out.println("Nilai UAS= " + uas);
System.out.println("Jadi nilai akhir adalah= " + NA);
}
}
==========================================================================
public class array{
public static void main (String[] args){
int nilai[] = {1,2,3,4,5,6};
for (int i=0;i<6;i++){
System.out.println(nilai[i]);
}
}
}
==========================================================================
public class array2D{
public static void main (String[] args){
int nilai[][] = {{1,2,3,4,5,6},
{6,7,8,9,10},
{11,12,13,14,15,16}};
for (int i=0;i<6;i++){
for (int j=0;j<i;j++)
System.out.println(nilai[i][j]+" ");
System.out.println(" ");
}
}
}
===========================================================================
import java.util.Scanner;
public class array2D {
public static void main (String[] args)
{ Scanner input=new Scanner(System.in);
String [][] kata={
{"one","satu"},{"cow","sapi"},{"run","lari"},{"red","merah"},{"man","orang"}
};
String katadicari;
System.out.print("Kata Yang Di Cari = ");
katadicari=input.nextLine();
int i,k;k=-1;
for (i=0;i<5;i++)
{
if(kata[i][0].equals(katadicari))
{
k=i;
}
}
if (k==-1)
{System.out.println ("kata yang di cari tidak ditemukan");
}
else
{
System.out.println("terjemahan = "+kata [k][1]);
}
}
===========================================================================
import java.util.Scanner;
public class array {
public static void main(String[] args){
int[][] Mat1 = new int[3][3];
Scanner s = new Scanner(System.in);
System.out.print("\n-Input Matriks-\n");
InputMatriks(Mat1);
System.out.print("\n-Matriks-\n");
tampilMatriks(Mat1);
System.out.print("\n Masukan variabel yang anda cari : "); int cari = s.nextInt();
cariMatriks(Mat1,cari);
}
public static void InputMatriks(int[][] matriks1){
Scanner scansod = new Scanner(System.in);
for(int i=0; i<matriks1.length;i++){
for(int j=0; j<matriks1[i].length;j++){
System.out.print(" Masukan elemen matriks A["+(i+1)+"]["+(j+1)+"]:");
matriks1[i][j]=scansod.nextInt();
}
}
}
public static void tampilMatriks(int[][] matriks){
for(int i=0; i<matriks.length;i++){
for(int j=0; j<matriks[0].length;j++){
System.out.print(" "+matriks[i][j]);
}System.out.print("\n");
}
}
public static void cariMatriks(int[][] matriks, int cari){
for(int i=0; i<matriks.length;i++){
for(int j=0; j<matriks[0].length-1;j++){
if(matriks[i][j]==cari){
System.out.print(" Variabel "+cari+" ada di matriks dengan baris "+(i+1)+" kolom "+(j+1)+"\n\n");
}
}
}
}
}
==========================================================================
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
String nama[] = new String[7];
Scanner input = new Scanner (System.in);
for (int i=0;i<6;i++){
System.out.println("inputkan ke "+ i +" = ");
nama[i] = input.next();
}
for(int i=0;i<6;i++){
System.out.println("inputkan ke "+ i +" = "+nama[i]);
}
}
}
===========================================================================
public class Main {
public static void main(String[] args) {
int a = 2;
int b = 15;
while (a<=b)
{
if (a % 2 == 1)
{
System.out.println(a++);
}
a++;
}
}
}
===========================================================================
package klasifikasinilai;
import javax.swing.JOptionPane;
/**
*
* @author Admin
*/
public class klasifikasinilai {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int quiz,uts,uas;
double na;
String grade, nilaistr;
JOptionPane.showMessageDialog(null, "Program Grade pada nilai");
//Masukkan nilai quiz
nilaistr = JOptionPane.showInputDialog(null,"Masukkan Nilai Quiz:");
quiz = Integer.parseInt(nilaistr);
//Masukkan nilai uts
nilaistr = JOptionPane.showInputDialog(null,"Masukkan Nilai UTS:");
uts = Integer.parseInt(nilaistr);
//masukkan nilai uas
nilaistr = JOptionPane.showInputDialog(null,"Masukkan Nilai UAS:");
uas = Integer.parseInt(nilaistr);
//Hitung nilai akhir
na = 0.2*quiz + 0.3*uts + 0.5*uas;
//kondisional grade
if (na > 80)
grade = "A";
else if ( na > 70)
grade = "B";
else if (na >55)
grade = "C";
else if (na > 40)
grade = "D";
else
grade ="E";
//Menampilkan Hasil
JOptionPane.showMessageDialog(null, "Nilai akhir = " + na + "grade: " + grade);
// TODO code application logic here
}
}
==========================================================================
class krucut{
double r;
double tinggi;
double vol;
double hitvol(double j,double t){
r = j;
tinggi = t;
vol = (Math.PI * r*r*tinggi)/3;
return vol;
}
}
public class luaskrucut{
public static void main(String[] args){
krucut k = new krucut();
k.r = 9;
k.tinggi = 12;
double volume = (3.14*k.r*k.r*k.tinggi)/3;
System.out.println(" Volume krucut = " +volume);
}
}
===========================================================================
class krucut{
double r;
double t;
public static void main(String[] args){
krucut k = new krucut();
k.r = 9;
k.t = 12;
double volume = (3.14*k.r*k.r*k.t)/3;
System.out.println(" Volume krucut = " +volume);
}
}
==============================================================================
class kotak{
double panjang;
double lebar;
double tinggi;
void cetakVolume(){
System.out.println("Volume Kotak= " + (panjang*lebar*tinggi));
}
}
public class luaskotak{
public static void main(String[] args){
kotak k = new kotak();
k.panjang = 6;
k.lebar = 9;
k.tinggi = 12;
k.cetakVolume();
}
}
============================================================================
import java.util.Scanner;
class menu{
double alas,panjang,lebar,tinggi,hasil;
double segitiga(double alas, double lebar, double tinggi){
alas = a;
tinggi = t;
hasil = (a*t)*0.5;
return hasil;
}
double persegipanjang(double panjang, double lebar){
panjang = p;
lebar = l;
hasil = p*l;
return hasil;
}
public static void main(String[] args){
menu isi = new menu();
System.out.println("");
System.out.println("===========================================");
System.out.println("Silahkan Pilih Menu untuk Menghitung Tabung");
System.out.println("===========================================");
System.out.println(" |1. Segitiga | ");
System.out.println(" |2. Persegi panjang| ");
System.out.println(" |0. Keluar | ");
System.out.println("===========================================");
System.out.print("Masukkan Pilihan Anda : ");
Scanner pilih = new Scanner(System.in);
int pilihan = pilih.nextInt();
if(pilihan == 1)
{
System.out.print("Masukan bilangan 1 : ");
double a = pilih.nextDouble();
System.out.print("Masukan bilangan 2 : ");
double b = pilih.nextDouble();
System.out.println("===========================================");
System.out.println("Hasil Penjumlahan : " +isi.segitiga );
System.out.println("");
}
if(pilihan == 2)
{
System.out.print("Masukan bilangan 1 : ");
double a = pilih.nextDouble();
System.out.print("Masukan bilangan 2 : ");
double b = pilih.nextDouble();
System.out.println("===========================================");
System.out.println("Hasil Perkalian : "+isi.persegipanjang);
System.out.println("");
}
if(pilihan == 0)
{
System.out.println("Terima Kasih");
System.out.println("**created by Radhitya**");
System.exit(0);
}
}
}
============================================================================
class Mobil {
String warna; //boleh terdiri dari banyak kelas
int tahun; //hanya ada satu void main //deklarasi nama kelas bebas
String merk;
}
class mobiljenazah{
class mobilsedan{
public static void main(String[] args){
Mobil mobil1 = new Mobil(); //cara membuat objek
mobil1.warna = "Hitam";
mobil1.tahun = 2004;
mobil1.merk = "Honda Jazz";
Mobil mobilJ = new Mobil();
mobilJ.warna = "Putih";
mobilJ.tahun = 2000;
mobilJ.merk = "Toyota Kijang";
System.out.println("Warnanya " + mobil1.warna);
System.out.println("Tahun= " + mobil1.tahun);
System.out.println("Merk= " + mobil1.merk);
System.out.println("Warnanya " + mobilJ.warna);
System.out.println("Tahun= " + mobilJ.tahun);
System.out.println("Merk= " + mobilJ.merk);
}
}
}
===========================================================================
thank gan infonya mampir ya http://blogs.unpas.ac.id/didik/2012/11/24/jurusan-teknik-informatika-6/
BalasHapus