SlideShare a Scribd company logo
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<String> title = new Vector<String>() ; 
public static void enter () 
{ 
for( int i=0;i<25;i++) 
{ 
System.out.println(""); 
} 
} 
public static void init(){ 
n = kata.length; 
for(int i=0;i<n;i++){ 
title.add(kata[i]); 
} 
title.remove(n-1); 
} 
public static void bubbleSortAsc(){ 
for(int i=0;i<n-1;i++){ 
for(int j=n-1;j>i;j--){ 
if(kata[j].compareTo (kata[j-1]) < 0){ 
String temp = kata[j-1]; 
kata[j-1] = kata[j]; 
kata[j] = temp; 
} 
} 
} 
} 
public static void bubbleSortDesc(){ 
for(int i=0;i<n-1;i++){ 
for(int j=n-1;j>i;j--){ 
if(kata[j].compareTo (kata[j-1]) > 0){ 
String temp = kata[j-1]; 
kata[j-1] = kata[j]; 
kata[j] = temp; 
} 
} 
} 
} 
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{ 
n = kata.length; 
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 <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(sort<1|| sort>2); 
if(sort ==1) 
{ 
bubbleSortAsc(); 
System.out.println("nSorting book by ascending"); 
System.out.println("============================"); 
for(int i=0;i<n;i++) 
{ 
System.out.print("-"+kata[i]+" n"); 
in.nextLine(); 
} 
n = title.size(); 
in.nextLine(); 
} 
else if(sort==2) 
{ 
bubbleSortDesc(); 
System.out.println("nSorting book by descending"); 
System.out.println("============================"); 
for(int i=0;i<n;i++) 
{
System.out.print("-"+kata[i]+" n"); 
in.nextLine(); 
} 
n = title.size(); 
//in.nextLine(); 
} 
break; 
case 2: 
enter(); 
do{ 
flag=0; 
try{ 
System.out.print("nInput your 
name :"); 
name = in.nextLine(); 
for (int a = 0; a < 
name.length(); a++) { 
if(name.charAt(a) >48 && 
name.charAt(a) <57) 
{ 
flag =1; 
} 
; 
} 
}catch(Exception e) 
{ 
in.nextLine(); 
flag=1; 
} 
}while(flag==1); 
do{ 
flag=0; 
try{ 
System.out.print("Input book title 
[prog=1,sci=2, acc=3, mene=4, pol=5] :"); 
judul =in.nextInt(); 
in.nextLine(); 
}catch(Exception e) 
{ 
in.nextLine(); 
flag=1; 
} 
}while(flag==1|| judul < 1 || judul > 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); 
} 
}

More Related Content

What's hot

Human-powered Javascript Compression for Fun and Gummy Bears
Human-powered Javascript Compression for Fun and Gummy BearsHuman-powered Javascript Compression for Fun and Gummy Bears
Human-powered Javascript Compression for Fun and Gummy Bears
Rui Lopes
 
Patrick Kettner - JavaScript without javascript
Patrick Kettner - JavaScript without javascriptPatrick Kettner - JavaScript without javascript
Patrick Kettner - JavaScript without javascript
OdessaJS Conf
 

What's hot (20)

ARCUS 도입기
ARCUS 도입기ARCUS 도입기
ARCUS 도입기
 
Human-powered Javascript Compression for Fun and Gummy Bears
Human-powered Javascript Compression for Fun and Gummy BearsHuman-powered Javascript Compression for Fun and Gummy Bears
Human-powered Javascript Compression for Fun and Gummy Bears
 
D3.js workshop
D3.js workshopD3.js workshop
D3.js workshop
 
The Ring programming language version 1.6 book - Part 44 of 189
The Ring programming language version 1.6 book - Part 44 of 189The Ring programming language version 1.6 book - Part 44 of 189
The Ring programming language version 1.6 book - Part 44 of 189
 
Efnsjdnfsuies
EfnsjdnfsuiesEfnsjdnfsuies
Efnsjdnfsuies
 
Numerical Method Assignment
Numerical Method AssignmentNumerical Method Assignment
Numerical Method Assignment
 
The Ring programming language version 1.5 book - Part 8 of 31
The Ring programming language version 1.5 book - Part 8 of 31The Ring programming language version 1.5 book - Part 8 of 31
The Ring programming language version 1.5 book - Part 8 of 31
 
The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196
 
Introduction to d3js (and SVG)
Introduction to d3js (and SVG)Introduction to d3js (and SVG)
Introduction to d3js (and SVG)
 
The Ring programming language version 1.3 book - Part 32 of 88
The Ring programming language version 1.3 book - Part 32 of 88The Ring programming language version 1.3 book - Part 32 of 88
The Ring programming language version 1.3 book - Part 32 of 88
 
Gems of GameplayKit. UA Mobile 2017.
Gems of GameplayKit. UA Mobile 2017.Gems of GameplayKit. UA Mobile 2017.
Gems of GameplayKit. UA Mobile 2017.
 
Master's Thesis
Master's ThesisMaster's Thesis
Master's Thesis
 
Integral table
Integral tableIntegral table
Integral table
 
The Ring programming language version 1.3 book - Part 21 of 88
The Ring programming language version 1.3 book - Part 21 of 88The Ring programming language version 1.3 book - Part 21 of 88
The Ring programming language version 1.3 book - Part 21 of 88
 
d3 is cool
d3 is coold3 is cool
d3 is cool
 
THE DATA DRIVEN WEB OF NOW: EXTENDING D3JS (Travis Smith)
THE DATA DRIVEN WEB OF NOW: EXTENDING D3JS (Travis Smith)THE DATA DRIVEN WEB OF NOW: EXTENDING D3JS (Travis Smith)
THE DATA DRIVEN WEB OF NOW: EXTENDING D3JS (Travis Smith)
 
関数プログラミングことはじめ revival
関数プログラミングことはじめ revival関数プログラミングことはじめ revival
関数プログラミングことはじめ revival
 
Patrick Kettner - JavaScript without javascript
Patrick Kettner - JavaScript without javascriptPatrick Kettner - JavaScript without javascript
Patrick Kettner - JavaScript without javascript
 
Intro To Agda
Intro To AgdaIntro To Agda
Intro To Agda
 
Javascript Without Javascript
Javascript Without JavascriptJavascript Without Javascript
Javascript Without Javascript
 

Similar to Booklab

Refer to my progress on this assignment belowIn this problem you w.pdf
Refer to my progress on this assignment belowIn this problem you w.pdfRefer to my progress on this assignment belowIn this problem you w.pdf
Refer to my progress on this assignment belowIn this problem you w.pdf
arishmarketing21
 
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdfJava AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
eyewatchsystems
 
Practice programs
Practice programsPractice programs
Practice programs
Abbott
 

Similar to Booklab (20)

Refer to my progress on this assignment belowIn this problem you w.pdf
Refer to my progress on this assignment belowIn this problem you w.pdfRefer to my progress on this assignment belowIn this problem you w.pdf
Refer to my progress on this assignment belowIn this problem you w.pdf
 
The Art of Clean Code
The Art of Clean CodeThe Art of Clean Code
The Art of Clean Code
 
ISCP internal.pdf
ISCP internal.pdfISCP internal.pdf
ISCP internal.pdf
 
Java Program
Java ProgramJava Program
Java Program
 
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdfJava AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
 
Java file
Java fileJava file
Java file
 
Java file
Java fileJava file
Java file
 
Practice programs
Practice programsPractice programs
Practice programs
 
Pnno
PnnoPnno
Pnno
 
ADA FILE
ADA FILEADA FILE
ADA FILE
 
Sam wd programs
Sam wd programsSam wd programs
Sam wd programs
 
Google Guava
Google GuavaGoogle Guava
Google Guava
 
Dotnet 18
Dotnet 18Dotnet 18
Dotnet 18
 
Basic program in java
Basic program in java Basic program in java
Basic program in java
 
Studyx4
Studyx4Studyx4
Studyx4
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple Programs
 
CBSE Class XII Comp sc practical file
CBSE Class XII Comp sc practical fileCBSE Class XII Comp sc practical file
CBSE Class XII Comp sc practical file
 
.net progrmming part2
.net progrmming part2.net progrmming part2
.net progrmming part2
 
Tips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET ApplicationTips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET Application
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
 

More from Ray Ray (6)

Code javascript
Code javascriptCode javascript
Code javascript
 
Code
CodeCode
Code
 
Code
CodeCode
Code
 
Code
CodeCode
Code
 
Code
CodeCode
Code
 
Laporan Counting Grade Apps
Laporan Counting Grade AppsLaporan Counting Grade Apps
Laporan Counting Grade Apps
 

Recently uploaded

Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
Avinash Rai
 

Recently uploaded (20)

Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
Forest and Wildlife Resources Class 10 Free Study Material PDF
Forest and Wildlife Resources Class 10 Free Study Material PDFForest and Wildlife Resources Class 10 Free Study Material PDF
Forest and Wildlife Resources Class 10 Free Study Material PDF
 
NLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxNLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptx
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resources
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Gyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptxGyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptx
 
[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
 
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
Operations Management - Book1.p  - Dr. Abdulfatah A. SalemOperations Management - Book1.p  - Dr. Abdulfatah A. Salem
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
 
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
 
Benefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational ResourcesBenefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational Resources
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
 

Booklab

  • 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<String> title = new Vector<String>() ; public static void enter () { for( int i=0;i<25;i++) { System.out.println(""); } } public static void init(){ n = kata.length; for(int i=0;i<n;i++){ title.add(kata[i]); } title.remove(n-1); } public static void bubbleSortAsc(){ for(int i=0;i<n-1;i++){ for(int j=n-1;j>i;j--){ if(kata[j].compareTo (kata[j-1]) < 0){ String temp = kata[j-1]; kata[j-1] = kata[j]; kata[j] = temp; } } } } public static void bubbleSortDesc(){ for(int i=0;i<n-1;i++){ for(int j=n-1;j>i;j--){ if(kata[j].compareTo (kata[j-1]) > 0){ String temp = kata[j-1]; kata[j-1] = kata[j]; kata[j] = temp; } } } } public static void main (String[]args) { init(); do{ System.out.println("ttt========="); System.out.println("tttBOOKS LAB"); System.out.println("ttt=========");
  • 2. System.out.println("n1. View List of Books"); System.out.println("2. Borrow Book"); System.out.println("3. Exit"); do{ n = kata.length; 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 <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(sort<1|| sort>2); if(sort ==1) { bubbleSortAsc(); System.out.println("nSorting book by ascending"); System.out.println("============================"); for(int i=0;i<n;i++) { System.out.print("-"+kata[i]+" n"); in.nextLine(); } n = title.size(); in.nextLine(); } else if(sort==2) { bubbleSortDesc(); System.out.println("nSorting book by descending"); System.out.println("============================"); for(int i=0;i<n;i++) {
  • 3. System.out.print("-"+kata[i]+" n"); in.nextLine(); } n = title.size(); //in.nextLine(); } break; case 2: enter(); do{ flag=0; try{ System.out.print("nInput your name :"); name = in.nextLine(); for (int a = 0; a < name.length(); a++) { if(name.charAt(a) >48 && name.charAt(a) <57) { flag =1; } ; } }catch(Exception e) { in.nextLine(); flag=1; } }while(flag==1); do{ flag=0; try{ System.out.print("Input book title [prog=1,sci=2, acc=3, mene=4, pol=5] :"); judul =in.nextInt(); in.nextLine(); }catch(Exception e) { in.nextLine(); flag=1; } }while(flag==1|| judul < 1 || judul > 5); do{ flag=0; try{ System.out.print("Input book quantity :"); qty = in.nextInt(); in.nextLine(); }catch(Exception e)
  • 4. { 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); } }