SlideShare uma empresa Scribd logo
1 de 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); 
} 
}

Mais conteúdo relacionado

Mais procurados

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
 

Mais procurados (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
 

Semelhante a 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
 

Semelhante a 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
 

Mais de 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
 

Mais de 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
 

Último

BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
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
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
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
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
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
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
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
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
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
 
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
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 

Último (20)

BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
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 ...
 
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"
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
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
 
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
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
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
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
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...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
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
 
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...
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 

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