Menu

Learn how to start playing on JartexNetwork in just 60 seconds!
Play Now
Learn how to join our server
and start playing in 60 seconds
Play Now
CLICK TO JOIN JOIN OUR DISCORD
0
0

How I didn’t know this existed

AUTHOR
AUTHOR
vortex91

vortex91

Addicted Member
Joined
May 12, 2020
Messages
2,020
Points
147
IGN
UntilNightfall
Java:
package workspace;


import java.util.Scanner;


    
    


    public class librarysystem{
        
        static int num = 0;
        
        static int invcount = 0;
        
        static int ct = 0;
        
        static librarysystem [] database = new librarysystem[20];
        
        static librarysystem [] inventory = new librarysystem[20];
    
        
        static Scanner sc = new Scanner(System.in);
        
        
        int pgcount;
        
        double price;
        
        
        String author = "";
        
        String title = "";
        
        int bknum;
        
        String ifs = "";
    
        
    
        
        
        
        
    
    
        
        
        public librarysystem(int pagecount, double totalprice, String author2, String name, int count, String av) {
            
            bknum = count;
            
            pgcount = pagecount;
            
            price = totalprice;
            
            author = author2;
            
            title = name;
            
            ifs = av;
            
            num++;
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
        }
        
        
        public static void display() {
            
            for(int i = 0; i < 2; i++) {
                
                
                
            System.out.println("Book Number: " + database[i].bknum);

            System.out.println("Title: " + database[i].title);
            
            System.out.println("Author: " + database[i].author);
            
            System.out.println("Page count: " + database[i].pgcount);
            
            System.out.println("Price: $" + database[i].price);
            
            System.out.println("Accessibility: " + database[i].ifs);
            
            
            
            
            System.out.println();
            
            
            }
        
        
        }
        
        
        
        
        public static void printinventory() {
            
            System.out.println("Here are the current books that you checked out.");
            
            System.out.println();
            
            for(int i = 0; i < invcount; i++) {
                
                System.out.println("Book Number: " + inventory[i].bknum);

                System.out.println("Title: " + inventory[i].title);
                
                System.out.println("Author: " + inventory[i].author);
                
                System.out.println("Page count: " + inventory[i].pgcount);
                
                System.out.println("Price: $" + inventory[i].price);
                
                
                
                
                
                System.out.println();
            }
            
            
        }
        
        
    
        
        
        public static void checkout() {
            
            System.out.println("Would you like to check out any books? y/n");
            
            String input3 = sc.nextLine();
            
            if(input3.equals("y")) {
                
                
                System.out.println("Please enter the book number(only one first) to check out any books");
                
                
                int input = sc.nextInt();
                
                if(input < num) {
                    
                    for(int i = 0; i < num; i++) {
                        
                        if(database[i].ifs.equals("Yes")) {
                            
                        
                        
                            if (database[i].bknum == input) {
                            
                                inventory[ct] = database[i];
                            
                                invcount++;
                            
                                ct++;
                            
                                database[i].ifs = "No";
                    
                            }
                            
                        }
                        
                        printinventory();
                        
                        
                        if(database[i].ifs.equals("No")) {
                            
                            
                            System.out.println("Sorry, that book is checked out.");
                            
                            
                        }
                        
                        
                        
                    
                    }
                    
                }
                
                
                
                if(input >= num) {
                    
                    System.out.println("That is not a valid book number.");
                        
                    checkout();
                    
                }
                    
            }
                
                
                
                
            
            
                    
                    
                    
            if(input3.equals("n")) {
                        
                System.out.println("Ok, come back later.");
                    

                }
                    
                    
        }
        
        
        
        public static void returnbk() {
            
            
        }
                
            
        
        
        
        public static void main(String[] args) {
            
            
            
            
            
            
            System.out.println("Welcome to the library! Would you like to take a look at our books? y/n");
            
            String input = sc.nextLine();
            
            librarysystem thehobbit = new librarysystem(310, 9.99, "J.R.R Tolkien","The Hobbit",1,"No");
            
            database[0] = thehobbit;
            
            librarysystem thelittleprince = new librarysystem(96, 11.99, "Antoine de Saint-Exupéry","The Little Prince",2,"Yes");
            
            database[1] = thelittleprince;
            
            if(input.equals("y")) {
                
                display();
                
                checkout();
                
                
            }
            
            
        
            
            

            
            
            
        }

                        
            
        
    
        
        
}
heres a big java project that im working on
 

SquareWings928

Great Reporter
Great Reporter
Donator
Joined
April 26, 2020
Messages
3,308
Points
227
IGN
SquareWings928
Java:
package workspace;


import java.util.Scanner;


   
   


    public class librarysystem{
       
        static int num = 0;
       
        static int invcount = 0;
       
        static int ct = 0;
       
        static librarysystem [] database = new librarysystem[20];
       
        static librarysystem [] inventory = new librarysystem[20];
   
       
        static Scanner sc = new Scanner(System.in);
       
       
        int pgcount;
       
        double price;
       
       
        String author = "";
       
        String title = "";
       
        int bknum;
       
        String ifs = "";
   
       
   
       
       
       
       
   
   
       
       
        public librarysystem(int pagecount, double totalprice, String author2, String name, int count, String av) {
           
            bknum = count;
           
            pgcount = pagecount;
           
            price = totalprice;
           
            author = author2;
           
            title = name;
           
            ifs = av;
           
            num++;
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
        }
       
       
        public static void display() {
           
            for(int i = 0; i < 2; i++) {
               
               
               
            System.out.println("Book Number: " + database[i].bknum);

            System.out.println("Title: " + database[i].title);
           
            System.out.println("Author: " + database[i].author);
           
            System.out.println("Page count: " + database[i].pgcount);
           
            System.out.println("Price: $" + database[i].price);
           
            System.out.println("Accessibility: " + database[i].ifs);
           
           
           
           
            System.out.println();
           
           
            }
       
       
        }
       
       
       
       
        public static void printinventory() {
           
            System.out.println("Here are the current books that you checked out.");
           
            System.out.println();
           
            for(int i = 0; i < invcount; i++) {
               
                System.out.println("Book Number: " + inventory[i].bknum);

                System.out.println("Title: " + inventory[i].title);
               
                System.out.println("Author: " + inventory[i].author);
               
                System.out.println("Page count: " + inventory[i].pgcount);
               
                System.out.println("Price: $" + inventory[i].price);
               
               
               
               
               
                System.out.println();
            }
           
           
        }
       
       
   
       
       
        public static void checkout() {
           
            System.out.println("Would you like to check out any books? y/n");
           
            String input3 = sc.nextLine();
           
            if(input3.equals("y")) {
               
               
                System.out.println("Please enter the book number(only one first) to check out any books");
               
               
                int input = sc.nextInt();
               
                if(input < num) {
                   
                    for(int i = 0; i < num; i++) {
                       
                        if(database[i].ifs.equals("Yes")) {
                           
                       
                       
                            if (database[i].bknum == input) {
                           
                                inventory[ct] = database[i];
                           
                                invcount++;
                           
                                ct++;
                           
                                database[i].ifs = "No";
                   
                            }
                           
                        }
                       
                        printinventory();
                       
                       
                        if(database[i].ifs.equals("No")) {
                           
                           
                            System.out.println("Sorry, that book is checked out.");
                           
                           
                        }
                       
                       
                       
                   
                    }
                   
                }
               
               
               
                if(input >= num) {
                   
                    System.out.println("That is not a valid book number.");
                       
                    checkout();
                   
                }
                   
            }
               
               
               
               
           
           
                   
                   
                   
            if(input3.equals("n")) {
                       
                System.out.println("Ok, come back later.");
                   

                }
                   
                   
        }
       
       
       
        public static void returnbk() {
           
           
        }
               
           
       
       
       
        public static void main(String[] args) {
           
           
           
           
           
           
            System.out.println("Welcome to the library! Would you like to take a look at our books? y/n");
           
            String input = sc.nextLine();
           
            librarysystem thehobbit = new librarysystem(310, 9.99, "J.R.R Tolkien","The Hobbit",1,"No");
           
            database[0] = thehobbit;
           
            librarysystem thelittleprince = new librarysystem(96, 11.99, "Antoine de Saint-Exupéry","The Little Prince",2,"Yes");
           
            database[1] = thelittleprince;
           
            if(input.equals("y")) {
               
                display();
               
                checkout();
               
               
            }
           
           
       
           
           

           
           
           
        }

                       
           
       
   
       
       
}
heres a big java project that im working on
What's its end purpose?
 

Top