booklab

Download Booklab

If you can't read please download the document

Upload: ray-ray

Post on 27-May-2015

33 views

Category:

Education


0 download

DESCRIPTION

booklab

TRANSCRIPT

  • 1. import java.util.*; public class booklab { static Scanner in = new Scanner(System.in); static String a, name,c=""; static int choice, flag,sort,no, judul, qty; static String kata[] = {"Programming","Accounting","Management","Science","Politics"}; static int n = kata.length; static Vector title = new Vector() ; public static void enter () { for( int i=0;i 0){ String temp = kata[j-1]; kata[j-1] = kata[j]; kata[j] = temp; } } } } public static void menu() { System.out.println("ttt========="); System.out.println("tttBOOKS LAB"); System.out.println("ttt========="); System.out.println("n1. View List of Books"); System.out.println("2. Borrow Book"); System.out.println("3. Exit");

2. do{ flag=0; try{ System.out.print("nInput Your Choice : "); choice = in.nextInt(); }catch(Exception e) { in.nextLine(); flag=1; } }while(flag==1 || choice 3); } public static void main (String[]args) { init(); do{ System.out.println("ttt========="); System.out.println("tttBOOKS LAB"); System.out.println("ttt========="); System.out.println("n1. View List of Books"); System.out.println("2. Borrow Book"); System.out.println("3. Exit"); do{ flag=0; try{ System.out.print("nInput Your Choice : "); choice = in.nextInt(); }catch(Exception e) { in.nextLine(); flag=1; } finally { in.nextLine(); } }while(flag==1 || choice 3); switch(choice) { case 1: enter(); do{ flag=0; try{ System.out.print("nPlease input sorting type[by asc=1 / desc=2] :"); sort = in.nextInt(); }catch(Exception e) { in.nextLine(); flag=1; } finally { in.nextLine(); } }while(sort2); if(sort ==1) 3. { bubbleSortAsc(); System.out.println("nSorting book by ascending"); System.out.println("============================"); for(int i=0;i48 && name.charAt(a) 5); do{ flag=0; try{ System.out.print("Input book quantity :"); qty = in.nextInt(); in.nextLine(); }catch(Exception e) { in.nextLine(); flag=1; } }while(flag==1); if(judul == 1) { System.out.println("nThanks "+name); System.out.println("You have borrowed "+qty+ " Programming book"); }else if(judul == 2) { System.out.println("nThanks " +name); System.out.println("You have borrowed "+qty+ " Science book"); }else if(judul ==3) { System.out.println("nThanks " +name); System.out.println("You have borrowed "+qty+ " Accounting book"); }else if(judul==4) { System.out.println("nThanks " +name); System.out.println("You have borrowed "+qty+ " Management book"); }else if(judul==5) { System.out.println("nThanks " +name); System.out.println("You have borrowed "+qty+ " Politics book"); } break; } }while(choice !=3); } }