Program INPUT DATA BUKU sederhana menggunakan java netbeans
//sourceCode:
_______________________________________________________________________________
package icikcik;
public class Pertama
{
private String[] name=new String [100];
private String[] alamate=new String [100];
private String[] telpone=new String [100];
private String[] emaile=new String [100];
private static int studentCount;
private static int indek;
public StudentRecord(){
studentCount=0;
}
public String getName(int indek)
{
return name[indek];
}
public String getAlamat(int indek)
{
return alamate[indek];
}
public String getTelpon(int indek)
{
return telpone[indek];
}
public String getEmail(int indek)
{
return emaile[indek];
}
public void setName( String nama, int indek,String alamat,String telpon,String email)
{
name[indek] = nama;
alamate[indek] = alamat;
telpone[indek] = telpon;
emaile[indek] = email;
studentCount++;
}
public static int getStudentCount()
{
return studentCount;
}
}
=================================================
package icikcik;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class StudentRecordExample
{
public static void main( String[] args )
{
BufferedReader dataIn=new BufferedReader(new InputStreamReader(System.in));
String [] nama =new String[100];
String [] alamat =new String[100];
String [] telp =new String[100];
String [] email =new String[100];
int i=1;
//membuat 5 object StudentRecord
StudentRecord namaRecord = new StudentRecord();
System.out.print("Input Nama: ");
try{
nama[i]=dataIn.readLine();
}
catch(IOException e){
System.out.println("Erorr!");
}
System.out.print("Input Alamat: ");
try{
alamat[i]=dataIn.readLine();
}catch(IOException e)
{
System.out.println("Erorr!");
}
System.out.print("Input telpon: ");
try{
telp[i]=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
System.out.print("Input Email: ");
try{
email[i]=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
namaRecord.setName(nama[i],i,alamat[i],telp[i],email[i]);
System.out.println("===========================================");
System.out.println("Nama Buku :"+namaRecord.getName(i) );
System.out.println("Penerbit Buku :"+namaRecord.getAlamat(i) );
System.out.println("Jenis Buku :"+namaRecord.getTelpon(i) );
System.out.println("Email :"+namaRecord.getEmail(i) );
System.out.println("===========================================");
System.out.println("\nTotal Jumlah Siswa ="+StudentRecord.getStudentCount());
}
}
__________________________________________________________________________________
package icikcik;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class StudentMenu
{
public static void main( String[] args ){
StudentRecord namaRecord = new StudentRecord();
BufferedReader dataIn=new BufferedReader(new InputStreamReader(System.in));
String [] nama =new String[100];
String [] alamat =new String[100];
String [] telp =new String[100];
String [] email =new String[100];
String PIL="";
String n="";
String yatidak="";
int no;
int jumlah=0;
do {
try {
System.out.println("MENU PILIHAN");
System.out.println(" 1. MEMASUKAN DATA **");
System.out.println(" 2. MENGHAPUS DATA **");
System.out.println(" 3. MENAMPILKAN DATA **");
System.out.println(" 4. MENGUBAH DATA **");
System.out.println(" 5. KELUAR **");
System.out.println("===============================");
System.out.print("\nMASUKAN PILIHAN :");
try{
PIL=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
//Menampilkan nama siswa
switch(Integer.parseInt(PIL)){
//awal prosedur memasukan
case 1:
System.out.print("Input Jumlah Buku Baru:");
try{
n=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
jumlah=Integer.parseInt(n);
for(int i=0; i<jumlah; i++ ){
System.out.println("Data ke: "+(i+1));
System.out.print("Input Nama Buku : ");
try{
nama[i]=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
System.out.print("Input Nama Penerbit: ");
try{
alamat[i]=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
System.out.print("Input Jenis Buku: ");
try{
telp[i]=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
System.out.print("Input Email: ");
try{
email[i]=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
}
for(int i=0; i<jumlah; i++ ){
namaRecord.setName(nama[i],i,alamat[i],telp[i],email[i]);
System.out.println("===========================================");
System.out.println("Nama Buku :"+namaRecord.getName(i) );
System.out.println("Penerbit Buku :"+namaRecord.getAlamat(i) );
System.out.println("Jenis Buku :"+namaRecord.getTelpon(i) );
System.out.println("Email :"+namaRecord.getEmail(i) );
System.out.println("===========================================");
}
System.out.println("Data Telah Berhasil dimasukan");
break;
//AKHIR prosedur memasukan
case 2:
System.out.println("Menghapus Data");
System.out.print("Input No BUKU yang Akan Dihapus: Input [1-"+jumlah+"]: ");
try{
n=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
no=Integer.parseInt(n);
System.out.println("Ditemukan Data ke- "+no);
no=no-1;
namaRecord.setName(nama[no],no,alamat[no],telp[no],email[no]);
System.out.println("===========================================");
System.out.println("Nama Buku :"+namaRecord.getName(no) );
System.out.println("Penerbit Buku :"+namaRecord.getAlamat(no) );
System.out.println("Jenis Buku :"+namaRecord.getTelpon(no) );
System.out.println("Email :"+namaRecord.getEmail(no) );
System.out.println("===========================================");
System.out.print("Yakin akan dihapus? [y]/[t] :");
try{
yatidak=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
if ((yatidak=="tidak")||(yatidak=="t")||(yatidak=="T")){
System.out.println("Data Tidak Jadi di hapus");
}else{
nama[no]="";
alamat[no]="";
telp[no]="";
email[no]="";
namaRecord.setName(nama[no],no,alamat[no],telp[no],email[no]);
System.out.println("===========================================");
System.out.println("Nama Buku :"+namaRecord.getName(no) );
System.out.println("Penerbit Buku :"+namaRecord.getAlamat(no) );
System.out.println("Jenis Buku :"+namaRecord.getTelpon(no));
System.out.println("Email :"+namaRecord.getEmail(no) );
System.out.println("===========================================");
System.out.println("Data Berhasil Dihapus");
}
break;
case 3:
System.out.println("DAFTAR SEMUA DATA BUKU");
System.out.println("===========================================");
for(int i=0; i<jumlah; i++ ){
namaRecord.setName(nama[i],i,alamat[i],telp[i],email[i]);
System.out.println("Nama Buku :"+namaRecord.getName(i) );
System.out.println("Penerbit Buku :"+namaRecord.getAlamat(i) );
System.out.println("Jenis Buku :"+namaRecord.getTelpon(i) );
System.out.println("Email :"+namaRecord.getEmail(i) );
System.out.println("===========================================");
}
break;
case 4:
System.out.println("Mengubah Data");
System.out.print("Input No Siswa yang Akan Diubah datanya: Input [1-"+jumlah+"]: ");
try{
n=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
no=Integer.parseInt(n);
System.out.println("Ditemukan Data ke- "+no);
no=no-1;
namaRecord.setName(nama[no],no,alamat[no],telp[no],email[no]);
System.out.println("===========================================");
System.out.println("Nama Buku :"+namaRecord.getName(no) );
System.out.println("Penerbit Buku :"+namaRecord.getAlamat(no) );
System.out.println("Jenis Buku :"+namaRecord.getTelpon(no) );
System.out.println("Email :"+namaRecord.getEmail(no) );
System.out.println("===========================================");
System.out.print("Lanjutkan Proses Ubah Data? [y]/[t] :");
try{
yatidak=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
if ((yatidak=="tidak")||(yatidak=="t")||(yatidak=="T")){
System.out.println("Data Tidak Jadi di ubah");
}
else{
System.out.println("Proses Ubah Data ke: "+(no+1));
System.out.print("Input Nama Buku: ");
try{
nama[no]=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
System.out.print("Input Penerbit: ");
try{
alamat[no]=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
System.out.print("Input Jenis: ");
try{
telp[no]=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
System.out.print("Input Email: ");
try{
email[no]=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
namaRecord.setName(nama[no],no,alamat[no],telp[no],email[no]);
System.out.println("===========================================");
System.out.println("Nama Buku :"+namaRecord.getName(no) );
System.out.println("Penerbit Buku :"+namaRecord.getAlamat(no) );
System.out.println("Jenis Buku :"+namaRecord.getTelpon(no) );
System.out.println("Email :"+namaRecord.getEmail(no) );
System.out.println("===========================================");
System.out.println("Data Berhasil Diubah");
}
break;
default:
System.out.println("Terima Kasih");
}
}
catch (Exception e) {
System.out.println("inputTidakValid");
}
} while (Integer.parseInt(PIL) != 5);
}
}
//sourceCode:
_______________________________________________________________________________
package icikcik;
public class Pertama
{
private String[] name=new String [100];
private String[] alamate=new String [100];
private String[] telpone=new String [100];
private String[] emaile=new String [100];
private static int studentCount;
private static int indek;
public StudentRecord(){
studentCount=0;
}
public String getName(int indek)
{
return name[indek];
}
public String getAlamat(int indek)
{
return alamate[indek];
}
public String getTelpon(int indek)
{
return telpone[indek];
}
public String getEmail(int indek)
{
return emaile[indek];
}
public void setName( String nama, int indek,String alamat,String telpon,String email)
{
name[indek] = nama;
alamate[indek] = alamat;
telpone[indek] = telpon;
emaile[indek] = email;
studentCount++;
}
public static int getStudentCount()
{
return studentCount;
}
}
=================================================
package icikcik;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class StudentRecordExample
{
public static void main( String[] args )
{
BufferedReader dataIn=new BufferedReader(new InputStreamReader(System.in));
String [] nama =new String[100];
String [] alamat =new String[100];
String [] telp =new String[100];
String [] email =new String[100];
int i=1;
//membuat 5 object StudentRecord
StudentRecord namaRecord = new StudentRecord();
System.out.print("Input Nama: ");
try{
nama[i]=dataIn.readLine();
}
catch(IOException e){
System.out.println("Erorr!");
}
System.out.print("Input Alamat: ");
try{
alamat[i]=dataIn.readLine();
}catch(IOException e)
{
System.out.println("Erorr!");
}
System.out.print("Input telpon: ");
try{
telp[i]=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
System.out.print("Input Email: ");
try{
email[i]=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
namaRecord.setName(nama[i],i,alamat[i],telp[i],email[i]);
System.out.println("===========================================");
System.out.println("Nama Buku :"+namaRecord.getName(i) );
System.out.println("Penerbit Buku :"+namaRecord.getAlamat(i) );
System.out.println("Jenis Buku :"+namaRecord.getTelpon(i) );
System.out.println("Email :"+namaRecord.getEmail(i) );
System.out.println("===========================================");
System.out.println("\nTotal Jumlah Siswa ="+StudentRecord.getStudentCount());
}
}
__________________________________________________________________________________
package icikcik;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class StudentMenu
{
public static void main( String[] args ){
StudentRecord namaRecord = new StudentRecord();
BufferedReader dataIn=new BufferedReader(new InputStreamReader(System.in));
String [] nama =new String[100];
String [] alamat =new String[100];
String [] telp =new String[100];
String [] email =new String[100];
String PIL="";
String n="";
String yatidak="";
int no;
int jumlah=0;
do {
try {
System.out.println("MENU PILIHAN");
System.out.println(" 1. MEMASUKAN DATA **");
System.out.println(" 2. MENGHAPUS DATA **");
System.out.println(" 3. MENAMPILKAN DATA **");
System.out.println(" 4. MENGUBAH DATA **");
System.out.println(" 5. KELUAR **");
System.out.println("===============================");
System.out.print("\nMASUKAN PILIHAN :");
try{
PIL=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
//Menampilkan nama siswa
switch(Integer.parseInt(PIL)){
//awal prosedur memasukan
case 1:
System.out.print("Input Jumlah Buku Baru:");
try{
n=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
jumlah=Integer.parseInt(n);
for(int i=0; i<jumlah; i++ ){
System.out.println("Data ke: "+(i+1));
System.out.print("Input Nama Buku : ");
try{
nama[i]=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
System.out.print("Input Nama Penerbit: ");
try{
alamat[i]=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
System.out.print("Input Jenis Buku: ");
try{
telp[i]=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
System.out.print("Input Email: ");
try{
email[i]=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
}
for(int i=0; i<jumlah; i++ ){
namaRecord.setName(nama[i],i,alamat[i],telp[i],email[i]);
System.out.println("===========================================");
System.out.println("Nama Buku :"+namaRecord.getName(i) );
System.out.println("Penerbit Buku :"+namaRecord.getAlamat(i) );
System.out.println("Jenis Buku :"+namaRecord.getTelpon(i) );
System.out.println("Email :"+namaRecord.getEmail(i) );
System.out.println("===========================================");
}
System.out.println("Data Telah Berhasil dimasukan");
break;
//AKHIR prosedur memasukan
case 2:
System.out.println("Menghapus Data");
System.out.print("Input No BUKU yang Akan Dihapus: Input [1-"+jumlah+"]: ");
try{
n=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
no=Integer.parseInt(n);
System.out.println("Ditemukan Data ke- "+no);
no=no-1;
namaRecord.setName(nama[no],no,alamat[no],telp[no],email[no]);
System.out.println("===========================================");
System.out.println("Nama Buku :"+namaRecord.getName(no) );
System.out.println("Penerbit Buku :"+namaRecord.getAlamat(no) );
System.out.println("Jenis Buku :"+namaRecord.getTelpon(no) );
System.out.println("Email :"+namaRecord.getEmail(no) );
System.out.println("===========================================");
System.out.print("Yakin akan dihapus? [y]/[t] :");
try{
yatidak=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
if ((yatidak=="tidak")||(yatidak=="t")||(yatidak=="T")){
System.out.println("Data Tidak Jadi di hapus");
}else{
nama[no]="";
alamat[no]="";
telp[no]="";
email[no]="";
namaRecord.setName(nama[no],no,alamat[no],telp[no],email[no]);
System.out.println("===========================================");
System.out.println("Nama Buku :"+namaRecord.getName(no) );
System.out.println("Penerbit Buku :"+namaRecord.getAlamat(no) );
System.out.println("Jenis Buku :"+namaRecord.getTelpon(no));
System.out.println("Email :"+namaRecord.getEmail(no) );
System.out.println("===========================================");
System.out.println("Data Berhasil Dihapus");
}
break;
case 3:
System.out.println("DAFTAR SEMUA DATA BUKU");
System.out.println("===========================================");
for(int i=0; i<jumlah; i++ ){
namaRecord.setName(nama[i],i,alamat[i],telp[i],email[i]);
System.out.println("Nama Buku :"+namaRecord.getName(i) );
System.out.println("Penerbit Buku :"+namaRecord.getAlamat(i) );
System.out.println("Jenis Buku :"+namaRecord.getTelpon(i) );
System.out.println("Email :"+namaRecord.getEmail(i) );
System.out.println("===========================================");
}
break;
case 4:
System.out.println("Mengubah Data");
System.out.print("Input No Siswa yang Akan Diubah datanya: Input [1-"+jumlah+"]: ");
try{
n=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
no=Integer.parseInt(n);
System.out.println("Ditemukan Data ke- "+no);
no=no-1;
namaRecord.setName(nama[no],no,alamat[no],telp[no],email[no]);
System.out.println("===========================================");
System.out.println("Nama Buku :"+namaRecord.getName(no) );
System.out.println("Penerbit Buku :"+namaRecord.getAlamat(no) );
System.out.println("Jenis Buku :"+namaRecord.getTelpon(no) );
System.out.println("Email :"+namaRecord.getEmail(no) );
System.out.println("===========================================");
System.out.print("Lanjutkan Proses Ubah Data? [y]/[t] :");
try{
yatidak=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
if ((yatidak=="tidak")||(yatidak=="t")||(yatidak=="T")){
System.out.println("Data Tidak Jadi di ubah");
}
else{
System.out.println("Proses Ubah Data ke: "+(no+1));
System.out.print("Input Nama Buku: ");
try{
nama[no]=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
System.out.print("Input Penerbit: ");
try{
alamat[no]=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
System.out.print("Input Jenis: ");
try{
telp[no]=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
System.out.print("Input Email: ");
try{
email[no]=dataIn.readLine();
}catch(IOException e){
System.out.println("Erorr!");
}
namaRecord.setName(nama[no],no,alamat[no],telp[no],email[no]);
System.out.println("===========================================");
System.out.println("Nama Buku :"+namaRecord.getName(no) );
System.out.println("Penerbit Buku :"+namaRecord.getAlamat(no) );
System.out.println("Jenis Buku :"+namaRecord.getTelpon(no) );
System.out.println("Email :"+namaRecord.getEmail(no) );
System.out.println("===========================================");
System.out.println("Data Berhasil Diubah");
}
break;
default:
System.out.println("Terima Kasih");
}
}
catch (Exception e) {
System.out.println("inputTidakValid");
}
} while (Integer.parseInt(PIL) != 5);
}
}