Sie sind auf Seite 1von 11

/*

* To change this template, choose Tools | Templates

FUNGSI 3 METHOD

* and open the template in the editor.

/*

*/

* To change this template, choose Tools | Templates

package fungsi3a;

* and open the template in the editor.

/**

*/

package fungsi3;

* @author LAB1AMIKOM

/**

*/

public class Fungsi3a

* @author LAB1AMIKOM

*/
public static int jumlah(){
int a= 7, b= 15;

public class Fungsi3


{

return (a +b);

public static int jumlah(){

int a= 7, b= 15;

/**

return (a +b);

* @param args the command line arguments

*/

/**

public static void main(String[] args) {

* @param args the command line arguments

// TODO code application logic here

*/

Fungsi3a obyek = new Fungsi3a ();

public static void main(String[] args) {

System.out.println("Hasil pemanggilan method jumlah");

// TODO code application logic here

System.out.println(obyek.jumlah());

System.out.println("Hasil pemanggilan method jumlah");

System.out.println(jumlah());

}
}

fungsi method kuis

FUNGSI PARAMETER

* To change this template, choose Tools | Templates

/*

* and open the template in the editor.

* To change this template, choose Tools | Templates

*/

* and open the template in the editor.

package kuis;

*/

/**

package fungsiparameter;

/**

* @author LAB1AMIKOM

*/

* @author LAB1AMIKOM

public class Kuis {

*/

public static int jumlah(){


int a= 7, b= 15;

public class Fungsiparameter


{
public static int jumlah (int a){

return (a +b);

return a;

}
}

public static int kurang(){


int a= 7, b= 15;

/**

return (a -b);

* @param args the command line arguments

*/

public static int kali(){

public static void main(String[] args) {

int a= 7, b= 15;

// TODO code application logic here

return (a*b);

System.out.println("Hasil pemanggilan methode");


System.out.println(jumlah (5));

}
}

public static int bagi(){


int a= 7, b= 15;
return (a/b);
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Kuis hitung=new Kuis();
System.out.println("perhitungan:"+hitung.jumlah());
System.out.println("perhitungan:"+hitung.kurang());
System.out.println("perhitungan:"+hitung.kali());
System.out.println("perhitungan:"+hitung.bagi());
}
}

FUNGSI 1 methode

/**

/*

* @param args the command line arguments

* To change this template, choose Tools | Templates

*/

* and open the template in the editor.

public static void main(String[] args) {

*/

// TODO code application logic here

package fungsi1;

Scanner input = new Scanner(System.in);

/**

int data_lulus[] [] = new int[2][3];

int tahun, jurusan;

* @author LAB1AMIKOM

data_lulus[0][0] = 110;

*/

data_lulus[0][1] = 125;

public class Fungsi1 {

data_lulus[0][2] = 135;

public static void garis (){

data_lulus[1][0] = 56;

System .out.println("==========================");

data_lulus[1][1] = 75;

data_lulus[1][2] = 85;

/**

System.out.print("Jurusan(0=TI, I=SI)=");

* @param args the command line arguments

jurusan = input.nextInt();

*/

if ((jurusan ==0)||(jurusan==1))

public static void main(String[] args) {

// TODO code application logic here

System.out.print("Tahun(2006-2008): ");

garis();

tahun=input.nextInt();

System.out.println("NO NAMA ALAMAT");

tahun-=2006;

garis();

else tahun =-1;

if((tahun>=0)&&(tahun<=2))
{

Data Lulusan

System.out.println("jumlah lulusan="

/*

+data_lulus[jurusan][tahun]);

* To change this template, choose Tools | Templates

* and open the template in the editor.

else System.out.println("Salah Inputan"

*/
package larik8;
import java.util.Scanner;
/**
*
* @author Ozi
*/
public class Larik8 {

}
}

total = total + nilai[i] [j];

LARIK 3
* To change this template, choose Tools | Templates

rata =total/5;

* and open the template in the editor.

System.out.println("Total data = "+total);

*/

System.out.println("Rata-rata = "+rata);
}

package larik3;

import java.util.Scanner;

Mencari Bilangan Ganjil dan genap


/**

* To change this template, choose Tools | Templates

* and open the template in the editor.

* @author LAB1AMIKOM

*/

*/

package latihan.pkg3;

public class Larik3 {

import java.util.Scanner;
/**

/**

* @param args the command line arguments

* @author LAB1AMIKOM

*/

*/

public static void main(String[] args) {

public class Latihan3 {

// TODO code application logic here

/**

Scanner masuk = new Scanner(System.in);

* @param args the command line arguments

float nilai[][]= new float[5][2];

*/

float total, rata;

public static void main(String[] args) {

System.out.println("Masukan data nilai");

// TODO code application logic here

for (int i = 0;i < 5; i++ )

int bilangan;

Scanner masuk=new Scanner(System.in);


for (int j = 0; j<2 ; j++){

System.out.print("Masukan Bilangan : ");

System.out.print((i + 1)+ "dan"+ (j+1)+ ":");

bilangan = masuk.nextInt();

nilai[i][j] = masuk.nextInt();

if (bilangan % 2 ==0){

System.out.println("Bilangan Genap");

}else {
System.out.println("Data niali yang dimasukan");

System.out.println("Bilangan Ganjil");

for (int i = 0; i < 5; i++)

{for (int j = 0; j < 2; j++)

{ System.out.println(nilai [i][j]);
}
}
total = 0;
for (int i = 0; i < 5 ; i++)
for (int j = 0; j < 2; j++)

LUAS LINGKARAN
Scanner input = new Scanner(System.in);
int r, Luas;

System.out.println("jumlah perkalian "+A+" X "+B+" = " +


kali);
System.out.println("jumlah pembagian "+A+" / "+B+" = " +
bagi);

System.out.print("masukkan jari-jari:");
r = input.nextInt();

}
}

Luas = (22*r*r)/7;
PENJUMLAHAN
System.out.println("Luas Lingkaran adalah: "+Luas);

package prj3;
import java.util.Scanner;

LUAS SEGETIGA

/**

Scanner masuk = new Scanner(System.in);

int a, t, alas, tinggi, bagi2, Luas;

* @author LAB1AMIKOM

System.out.print("alas : ");

*/

a = masuk.nextInt();

public class PRJ3 {

System.out.print("tinggi : ");

/**

t = masuk.nextInt();

* @param args the command line arguments

Luas = (a * t) /2;

*/
public static void main(String[] args) {

System.out.print("alas * tinggi /2=");

// TODO code application logic here

System.out.println("Luas segitiga adalah " + Luas);

Scanner masuk = new Scanner(System.in);


int a,b,c;

PENJUMLAHAN

System.out.print("Masukan Bilangan 1: ");


a=masuk.nextInt();

Scanner masuk = new Scanner(System.in);

System.out.print("Masukan Bilangan 2: ");

int A, B, jumlah, kurang, kali, bagi;

b=masuk.nextInt();

System.out.print("Bilangan 1 : ");

c=a+b;

A = masuk.nextInt();

System.out.println("Hasil penjumlahan="+c);

System.out.print("Bilangan 2 : ");
B = masuk.nextInt();
jumlah = A + B;
kurang = A - B;
kali = A * B;
bagi = A / B;

System.out.println("jumlah Penjumlahan "+A+" + "+B+" = "


+ jumlah);
System.out.println("jumlah pengurangan "+A+" - "+B+" = " +
kurang);

public class Array {

ARRAY 1-100
/*

/**

* To change this template, choose Tools | Templates

* @param args the command line arguments

* and open the template in the editor.

*/

*/

public static void main(String[] args) {

package arraysample;

// TODO code application logic here

/**

int array[];

array = new int[7];

* @author LAB1AMIKOM
*/

array[0] = 5;

public class ArraySample {

array[1] = 8;

/**

array[2] = 20;

* @param args the command line arguments

array[3] = 9;

*/

array[5] = 10;

public static void main(String[] args) {

for(int i=0; i<7; i++)

// TODO code application logic here

int[]ages = new int[100];

System.out.println("array["+i+"]="+array[i]);
}

for(int i=0;i<100;i++)
{

}
}

ages[i]=i+1;
System.out.print(ages[i]+" ");

ARRAY

package array;
}

public class Array {

}
public static void main(String[] args) {

ARRAY

int array[];

/*

array = new int[5];

* To change this template, choose Tools | Templates


* and open the template in the editor.
*/
package array;
/**
*

array[0] = 5;
array[1] = 8;
array[2] = 20;
for(int i=0; i<5; i++)
{

* @author LAB1AMIKOM
*/

System.out.println("array["+i+"]="+array[i]);
}

Nim[i] = in.next();

System.out.print("\tNama : ");

ARRAY SAMPLE

Nama[i] = in.next();

package arraysample;

System.out.print("\tAlamat : ");

public class ArraySample {

Alamat[i] = in.next();

public static void main(String[] args) {

System.out.print("\tKota : ");

int[]ages = new int[100];

Kota[i] = in.next();
System.out.print("\tTelepon : ");

for(int i=0; i<ages.length;i++){

Telp[i] = in.next();

System.out.print(ages[i]);

System.out.print("\tJenis Kelamin : ");

Jns_k[i] = in.next();
}

System.out.print("\tTinggi Badan : ");

Tinggi[i] = in.nextInt();

ARRAY

System.out.println();

package javaapplication13;

}
System.out.println("Laporan:");

import java.util.Scanner;

System.out.println("\t\tLAPORAN DATA MAHASISWA");

public class JavaApplication13 {


public static void main(String[] args) {
Scanner in = new Scanner(System.in);

System.out.println("\t\tSTMIK AMIKOM PURWOKERTO");


System.out.println("No. NIM Nama Mahasiswa Alamat Telp
Tinggi");
for (i = 0; i < data; i++) {

String Nim[] = new String[100];


String Nama[] = new String[100];

System.out.println((i + 1) + "\t" + Nim[i] + "\t" + Nama[i]


+ "\t" + Alamat[i]

String Alamat[] = new String[100];

+ "\t" + Tinggi[i]);

String Kota[] = new String[100];

String Telp[] = new String[100];


String Jns_k[] = new String[100];
int Tinggi[] = new int[100];
int data, i;

System.out.println("Data Mahasiswa");
System.out.println("Masukkan Jumlah Data: ");
data = in.nextInt();

for (i = 0; i < data; i++) {


System.out.println("Mahasiswa ke- " + (i + 1));
System.out.print("\tNim : ");

}
}

BUFFERED RAIDER

BUFFERED RAIDER

package praktikum1;

import java.io.BufferedReader;

import javax.swing.JOptionPane;

import java.io.InputStreamReader;

import java.util.Scanner;

import java.io.EOFException;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;
import java.io.IOException;

public class Ck_BufferedReader {


public static void main(String[] args) {

public class Kombinasi_3_input {


public static void main(String[] args){

BufferedReader input = new BufferedReader(new


InputStreamReader(System.in));

//scanner
System.out.println("carikode.com \n");

Scanner input = new Scanner (System.in);


System.out.println("First Number : ");
String fn = input.nextLine();

String nama =" " ;

//Buffered Reader

System.out.print("masukkan nama anda ");

BufferedReader dataIn = new BufferedReader(new


InputStreamReader(System.in));

try {
nama = input.readLine();

String sn = "";
}

System.out.print("Second Number : ");

catch(IOException e){

try {

System.out.println("ERROR");

sn = dataIn.readLine();
}

}
catch(IOException e) {

String alamat = "";

System.out.println("Error!");

System.out.print("masukkan alamat anda ");

try{

//JOptionPane

alamat = input.readLine();

String tn = JOptionPane.showInputDialog("Third
Number : ");
int n1 = Integer.parseInt(fn);

int n2 = Integer.parseInt(sn);

catch(IOException e){

int n3 = Integer.parseInt(tn);

System.out.println("ERROR");

int hasil = (n1*n2)/n3;

JOptionPane.showMessageDialog(null, "Jawaban dari ( "


+fn +" x " +sn +" ) : " +tn +" = " +hasil,

System.out.println("selamat datang " + nama);


System.out.println("tempat dinggal anda di " +alamat);

"JAWABAN", JOptionPane.PLAIN_MESSAGE);
}
}

String alamat=" " ;

BUFFERED RAIDER

System.out.print("Alamat: ");

/*import java.io.* ;

try {
alamat = input.readLine();

* To change this template, choose Tools | Templates


* and open the template in the editor.

*/

catch(IOException e){
System.out.println("ERROR");

package bufferedreader.hendrapradiptiya.pkg15.pkg12.pkg0064;
import java.io.*;

/**

String TTL=" " ;

System.out.print("Tempat Tanggal Lahir: ");

* @author Hendra

try {
TTL = input.readLine();

*/
public class BufferedreaderHendrapradiptiya15120064 {

}
catch(IOException e){
System.out.println("ERROR");

/**
* @param args the command line arguments

*/

String jeniskelamin=" " ;

public static void main(String[] args) {

System.out.print("Jenis Kelamin : ");

// TODO code application logic here


BufferedReader input = new BufferedReader(new
InputStreamReader(System.in));
System.out.println("Data Mahasiswa \n");

try {
jeniskelamin = input.readLine();
}
catch(IOException e){

String NIM =" " ;


System.out.print("NIM: ");
try {
NIM = input.readLine();
}

System.out.println("ERROR");
}
String hobi=" " ;
System.out.print("Hobi : ");
try {

catch(IOException e){
System.out.println("ERROR");
}

hobi = input.readLine();
}
catch(IOException e){

String nama = "";


System.out.print("Nama: ");
try{
nama = input.readLine();
}

System.out.println("ERROR");
}
String notelepon=" " ;
System.out.print("Telepon: ");
try {

catch(IOException e){
System.out.println("ERROR");
}

notelepon = input.readLine();
}
catch(IOException e){

System.out.println("ERROR");

Scanner in = new Scanner(System.in);

int jumlah = in.nextInt();

String tinggibadan=" " ;

String[] nama = new String[jumlah];

System.out.print("Tinggi Badan : ");

String temp;

try {
tinggibadan = input.readLine();
}
catch(IOException e){

public void TambahData() throws IOException {


InputStreamReader data = new
InputStreamReader(System.in);
BufferedReader dtmasuk = new BufferedReader(data);

System.out.println("ERROR");

for (int i = 0; i < jumlah; i++) {

System.out.println("Nama: ");

System.out.println("Berdasarkan data yang anda inputkan


NIM anda adalah " + NIM);

nama[i] = dtmasuk.readLine();

System.out.println("Nama anda " +nama);

System.out.println("Anda beralamat di " +alamat);

System.out.println("Anda lahir di " +TTL);


System.out.println("Berjenis kelamin " +jeniskelamin);

public void TampilUrutData() {

System.out.println("Hobi anda adalah " +hobi);

for (int i = 0; i < (jumlah - 1); i++) {

System.out.println("No telepon " +notelepon);


System.out.println("Tinggi badan anda " +tinggibadan);

for (int j = 0; j < (jumlah - 1); j++) {

if (nama[j].compareTo(nama[j + 1]) > 0) {

temp = nama[j + 1];

BUFFERED RAIDER

nama[j + 1] = nama[j];
nama[j] = temp;

Responsi projek utama urut kata


}

/*
}

* To change this template, choose Tools | Templates


}

* and open the template in the editor.

for (int i = 0; i < jumlah; i++) {

*/

System.out.println(i + 1 + " " + nama[i]);

package prjutamaurutkata;
}

import java.io.BufferedReader;
}

import java.io.IOException;
import java.io.InputStreamReader;

public static void main(String[] args) throws IOException {

import java.util.Scanner;

System.out.println("Masukkan Jumlah Data: ");

/**

PrjUtamaUrutKata masuk = new PrjUtamaUrutKata();

masuk.TambahData();

* @author Aspire

masuk.TampilUrutData();

*/
}

public class PrjUtamaUrutKata {


}

* @author LAB1AMIKOM
DO WHILE

*/

TAMPIL ANGKA 3 6 9 12 15

public class Prjlatihan11 {

package prjlatihan11;
public class Prjlatihan11 {

/**
* @param args the command line arguments

public static void main(String[] args) {


int bil = 3;

*/
public static void main(String[] args) {
// TODO code application logic here
int bil = 0;

do{
System.out.println(bil+"");

do{

bil= bil+3;

System.out.println("SI 15 C belajar java ");

}while(bil<=15);

bil++;
}while(bil<5);

}
}
}

DO WHILE
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package prjlatihan11;

/**
*

Das könnte Ihnen auch gefallen