SlideShare ist ein Scribd-Unternehmen logo
1 von 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{
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);
}
}

Weitere ähnliche Inhalte

Was ist angesagt?

Geek Time Janvier 2017 : Quiz Java
Geek Time Janvier 2017 : Quiz JavaGeek Time Janvier 2017 : Quiz Java
Geek Time Janvier 2017 : Quiz JavaOLBATI
 
Pick up the low-hanging concurrency fruit
Pick up the low-hanging concurrency fruitPick up the low-hanging concurrency fruit
Pick up the low-hanging concurrency fruitVaclav Pech
 
D3 svg & angular
D3 svg & angularD3 svg & angular
D3 svg & angular500Tech
 
java experiments and programs
java experiments and programsjava experiments and programs
java experiments and programsKaruppaiyaa123
 
Arrays, Structures And Enums
Arrays, Structures And EnumsArrays, Structures And Enums
Arrays, Structures And EnumsBhushan Mulmule
 
CS-141 Java programming II ASSIGNMENT 2
CS-141 Java programming II ASSIGNMENT 2CS-141 Java programming II ASSIGNMENT 2
CS-141 Java programming II ASSIGNMENT 2Voffelarin
 
The Ring programming language version 1.5.1 book - Part 28 of 180
The Ring programming language version 1.5.1 book - Part 28 of 180The Ring programming language version 1.5.1 book - Part 28 of 180
The Ring programming language version 1.5.1 book - Part 28 of 180Mahmoud Samir Fayed
 
Fast, stable and scalable true radix sorting with Matt Dowle at useR! Aalborg
Fast, stable and scalable true radix sorting with Matt Dowle at useR! AalborgFast, stable and scalable true radix sorting with Matt Dowle at useR! Aalborg
Fast, stable and scalable true radix sorting with Matt Dowle at useR! AalborgSri Ambati
 
Java & OOP Core Concept
Java & OOP Core ConceptJava & OOP Core Concept
Java & OOP Core ConceptPin-Lun Huang
 
design and analysis of algorithm Lab files
design and analysis of algorithm Lab filesdesign and analysis of algorithm Lab files
design and analysis of algorithm Lab filesNitesh Dubey
 
C# console programms
C# console programmsC# console programms
C# console programmsYasir Khan
 
The Ring programming language version 1.8 book - Part 35 of 202
The Ring programming language version 1.8 book - Part 35 of 202The Ring programming language version 1.8 book - Part 35 of 202
The Ring programming language version 1.8 book - Part 35 of 202Mahmoud Samir Fayed
 

Was ist angesagt? (20)

Geek Time Janvier 2017 : Quiz Java
Geek Time Janvier 2017 : Quiz JavaGeek Time Janvier 2017 : Quiz Java
Geek Time Janvier 2017 : Quiz Java
 
Uts
UtsUts
Uts
 
Pick up the low-hanging concurrency fruit
Pick up the low-hanging concurrency fruitPick up the low-hanging concurrency fruit
Pick up the low-hanging concurrency fruit
 
D3.js workshop
D3.js workshopD3.js workshop
D3.js workshop
 
D3 svg & angular
D3 svg & angularD3 svg & angular
D3 svg & angular
 
java experiments and programs
java experiments and programsjava experiments and programs
java experiments and programs
 
Arrays, Structures And Enums
Arrays, Structures And EnumsArrays, Structures And Enums
Arrays, Structures And Enums
 
Priority queues
Priority queuesPriority queues
Priority queues
 
CS-141 Java programming II ASSIGNMENT 2
CS-141 Java programming II ASSIGNMENT 2CS-141 Java programming II ASSIGNMENT 2
CS-141 Java programming II ASSIGNMENT 2
 
The Ring programming language version 1.5.1 book - Part 28 of 180
The Ring programming language version 1.5.1 book - Part 28 of 180The Ring programming language version 1.5.1 book - Part 28 of 180
The Ring programming language version 1.5.1 book - Part 28 of 180
 
Fast, stable and scalable true radix sorting with Matt Dowle at useR! Aalborg
Fast, stable and scalable true radix sorting with Matt Dowle at useR! AalborgFast, stable and scalable true radix sorting with Matt Dowle at useR! Aalborg
Fast, stable and scalable true radix sorting with Matt Dowle at useR! Aalborg
 
Java & OOP Core Concept
Java & OOP Core ConceptJava & OOP Core Concept
Java & OOP Core Concept
 
design and analysis of algorithm Lab files
design and analysis of algorithm Lab filesdesign and analysis of algorithm Lab files
design and analysis of algorithm Lab files
 
กลุ่ม6
กลุ่ม6กลุ่ม6
กลุ่ม6
 
C# console programms
C# console programmsC# console programms
C# console programms
 
The Ring programming language version 1.8 book - Part 35 of 202
The Ring programming language version 1.8 book - Part 35 of 202The Ring programming language version 1.8 book - Part 35 of 202
The Ring programming language version 1.8 book - Part 35 of 202
 
123
123123
123
 
ts
tsts
ts
 
C# labprograms
C# labprogramsC# labprograms
C# labprograms
 
Advance java
Advance javaAdvance java
Advance java
 

Andere mochten auch

Trabalho Rodrigo 23/09/2009
Trabalho Rodrigo 23/09/2009Trabalho Rodrigo 23/09/2009
Trabalho Rodrigo 23/09/2009Ricardo
 
Matriz de diseno_de_la_pregunta2011_actualizada3
Matriz de diseno_de_la_pregunta2011_actualizada3Matriz de diseno_de_la_pregunta2011_actualizada3
Matriz de diseno_de_la_pregunta2011_actualizada3harold acosta
 
Tag 2 E C Spand Share Point Convention
Tag 2  E C Spand  Share Point  ConventionTag 2  E C Spand  Share Point  Convention
Tag 2 E C Spand Share Point ConventionFLorian Laumer
 
Slides residuos jd juliana.1 .pptx
Slides residuos jd juliana.1 .pptxSlides residuos jd juliana.1 .pptx
Slides residuos jd juliana.1 .pptxLayara Malvestio
 
New Business, offshore data capture, Manolo de la Fuente
New Business, offshore data capture, Manolo de la FuenteNew Business, offshore data capture, Manolo de la Fuente
New Business, offshore data capture, Manolo de la FuenteManolo de la Fuente
 
Design Petro Hairsalon
Design Petro HairsalonDesign Petro Hairsalon
Design Petro Hairsalonsunniesunsun
 
tipos de conexión internet
tipos de conexión  internettipos de conexión  internet
tipos de conexión internetmaryoria
 
Clash new multiple-images constraining the inner mass profile of macs j1206....
Clash  new multiple-images constraining the inner mass profile of macs j1206....Clash  new multiple-images constraining the inner mass profile of macs j1206....
Clash new multiple-images constraining the inner mass profile of macs j1206....Sérgio Sacani
 

Andere mochten auch (9)

Trabalho Rodrigo 23/09/2009
Trabalho Rodrigo 23/09/2009Trabalho Rodrigo 23/09/2009
Trabalho Rodrigo 23/09/2009
 
Matriz de diseno_de_la_pregunta2011_actualizada3
Matriz de diseno_de_la_pregunta2011_actualizada3Matriz de diseno_de_la_pregunta2011_actualizada3
Matriz de diseno_de_la_pregunta2011_actualizada3
 
Tag 2 E C Spand Share Point Convention
Tag 2  E C Spand  Share Point  ConventionTag 2  E C Spand  Share Point  Convention
Tag 2 E C Spand Share Point Convention
 
Apresentação institucional português 1 t12
Apresentação institucional português 1 t12Apresentação institucional português 1 t12
Apresentação institucional português 1 t12
 
Slides residuos jd juliana.1 .pptx
Slides residuos jd juliana.1 .pptxSlides residuos jd juliana.1 .pptx
Slides residuos jd juliana.1 .pptx
 
New Business, offshore data capture, Manolo de la Fuente
New Business, offshore data capture, Manolo de la FuenteNew Business, offshore data capture, Manolo de la Fuente
New Business, offshore data capture, Manolo de la Fuente
 
Design Petro Hairsalon
Design Petro HairsalonDesign Petro Hairsalon
Design Petro Hairsalon
 
tipos de conexión internet
tipos de conexión  internettipos de conexión  internet
tipos de conexión internet
 
Clash new multiple-images constraining the inner mass profile of macs j1206....
Clash  new multiple-images constraining the inner mass profile of macs j1206....Clash  new multiple-images constraining the inner mass profile of macs j1206....
Clash new multiple-images constraining the inner mass profile of macs j1206....
 

Ähnlich wie Booklab

Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple ProgramsUpender Upr
 
Demonstrating bully algorithm in java
Demonstrating bully algorithm in javaDemonstrating bully algorithm in java
Demonstrating bully algorithm in javaNagireddy Dwarampudi
 
public class TrequeT extends AbstractListT { .pdf
  public class TrequeT extends AbstractListT {  .pdf  public class TrequeT extends AbstractListT {  .pdf
public class TrequeT extends AbstractListT { .pdfinfo30292
 
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
 
Java весна 2013 лекция 2
Java весна 2013 лекция 2Java весна 2013 лекция 2
Java весна 2013 лекция 2Technopark
 
Core java pract_sem iii
Core java pract_sem iiiCore java pract_sem iii
Core java pract_sem iiiNiraj Bharambe
 
Code javascript
Code javascriptCode javascript
Code javascriptRay Ray
 
C# Starter L04-Collections
C# Starter L04-CollectionsC# Starter L04-Collections
C# Starter L04-CollectionsMohammad Shaker
 
import java.util.ArrayList;public class Checkout{private.docx
import java.util.ArrayList;public class Checkout{private.docximport java.util.ArrayList;public class Checkout{private.docx
import java.util.ArrayList;public class Checkout{private.docxAbhinav816839
 
import java.util.Scanner; public class Palin { public static v.pdf
import java.util.Scanner; public class Palin { public static v.pdfimport java.util.Scanner; public class Palin { public static v.pdf
import java.util.Scanner; public class Palin { public static v.pdfLAMJM
 
Please help with this JAVA Assignment and show output if you can ple.pdf
Please help with this JAVA Assignment and show output if you can ple.pdfPlease help with this JAVA Assignment and show output if you can ple.pdf
Please help with this JAVA Assignment and show output if you can ple.pdfaroramobiles1
 

Ähnlich wie Booklab (20)

ISCP internal.pdf
ISCP internal.pdfISCP internal.pdf
ISCP internal.pdf
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple Programs
 
100 Small programs
100 Small programs100 Small programs
100 Small programs
 
Demonstrating bully algorithm in java
Demonstrating bully algorithm in javaDemonstrating bully algorithm in java
Demonstrating bully algorithm in java
 
public class TrequeT extends AbstractListT { .pdf
  public class TrequeT extends AbstractListT {  .pdf  public class TrequeT extends AbstractListT {  .pdf
public class TrequeT extends AbstractListT { .pdf
 
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 Program
Java ProgramJava Program
Java Program
 
Java весна 2013 лекция 2
Java весна 2013 лекция 2Java весна 2013 лекция 2
Java весна 2013 лекция 2
 
Core java pract_sem iii
Core java pract_sem iiiCore java pract_sem iii
Core java pract_sem iii
 
Code javascript
Code javascriptCode javascript
Code javascript
 
C# Starter L04-Collections
C# Starter L04-CollectionsC# Starter L04-Collections
C# Starter L04-Collections
 
Oot practical
Oot practicalOot practical
Oot practical
 
import java.util.ArrayList;public class Checkout{private.docx
import java.util.ArrayList;public class Checkout{private.docximport java.util.ArrayList;public class Checkout{private.docx
import java.util.ArrayList;public class Checkout{private.docx
 
Dotnet 18
Dotnet 18Dotnet 18
Dotnet 18
 
Java file
Java fileJava file
Java file
 
Java file
Java fileJava file
Java file
 
662305 09
662305 09662305 09
662305 09
 
Implementing stack
Implementing stackImplementing stack
Implementing stack
 
import java.util.Scanner; public class Palin { public static v.pdf
import java.util.Scanner; public class Palin { public static v.pdfimport java.util.Scanner; public class Palin { public static v.pdf
import java.util.Scanner; public class Palin { public static v.pdf
 
Please help with this JAVA Assignment and show output if you can ple.pdf
Please help with this JAVA Assignment and show output if you can ple.pdfPlease help with this JAVA Assignment and show output if you can ple.pdf
Please help with this JAVA Assignment and show output if you can ple.pdf
 

Mehr von Ray Ray

Laporan Counting Grade Apps
Laporan Counting Grade AppsLaporan Counting Grade Apps
Laporan Counting Grade AppsRay Ray
 

Mehr von Ray Ray (6)

Booklab
BooklabBooklab
Booklab
 
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
 

Kürzlich hochgeladen

Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxPoojaSen20
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinojohnmickonozaleda
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Kürzlich hochgeladen (20)

LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipino
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.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{ 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");
  • 3. 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); } }