SlideShare a Scribd company logo
1 of 4
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

ARCUS 도입기
ARCUS 도입기ARCUS 도입기
ARCUS 도입기JaM2in
 
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 BearsRui Lopes
 
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 189Mahmoud Samir Fayed
 
Efnsjdnfsuies
EfnsjdnfsuiesEfnsjdnfsuies
Efnsjdnfsuieshtmrk
 
Numerical Method Assignment
Numerical Method AssignmentNumerical Method Assignment
Numerical Method Assignmentashikul akash
 
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 31Mahmoud Samir Fayed
 
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 196Mahmoud Samir Fayed
 
Introduction to d3js (and SVG)
Introduction to d3js (and SVG)Introduction to d3js (and SVG)
Introduction to d3js (and SVG)zahid-mian
 
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 88Mahmoud Samir Fayed
 
Gems of GameplayKit. UA Mobile 2017.
Gems of GameplayKit. UA Mobile 2017.Gems of GameplayKit. UA Mobile 2017.
Gems of GameplayKit. UA Mobile 2017.UA Mobile
 
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 88Mahmoud Samir Fayed
 
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)Future Insights
 
関数プログラミングことはじめ revival
関数プログラミングことはじめ revival関数プログラミングことはじめ revival
関数プログラミングことはじめ revivalNaoki Kitora
 
Patrick Kettner - JavaScript without javascript
Patrick Kettner - JavaScript without javascriptPatrick Kettner - JavaScript without javascript
Patrick Kettner - JavaScript without javascriptOdessaJS Conf
 
Javascript Without Javascript
Javascript Without JavascriptJavascript Without Javascript
Javascript Without JavascriptPatrick Kettner
 

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.pdfarishmarketing21
 
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.pdfeyewatchsystems
 
Practice programs
Practice programsPractice programs
Practice programsAbbott
 
Basic program in java
Basic program in java Basic program in java
Basic program in java Sudeep Singh
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple ProgramsUpender Upr
 
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 filePranav Ghildiyal
 
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 ApplicationJoni
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File Rahul Chugh
 

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

Code javascript
Code javascriptCode javascript
Code javascriptRay Ray
 
Laporan Counting Grade Apps
Laporan Counting Grade AppsLaporan Counting Grade Apps
Laporan Counting Grade AppsRay Ray
 

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

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 

Recently uploaded (20)

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 

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); } }