Limited-time offer! Save up to 50% Off | Solutions starting at $6 each  

Added On : 26 Nov 2021

Part 4 – SCENARIO: What is Algorithm in Computer Science

Problem

  • In oder to maintance a library, we will have a program that can manage all of the information of users, the book and the author, so on. Each of object will have their function like : 
  • User can use their information to create a new account to rent book or return.
  • The book will have their code, their ISBN and their released date.
  • The publisher or the established will have their name so the reader can find their similar variety of book.

Solution

For the user : 
Step 1 . Input :
                 . Names
                 . ID number
                 . Phone number
Step 2 . Storage their information, the information will be used by the administrator for tracking the renting book.


Code, testing

Input the value for user information, book information, and another object that can have in the class.
Create the menu for the administrator to take control of all the programs which will maintain the activity of the library.
Create the object “ The reader “ who has their function as providing the information for the administration.
 

→For the opening of the program, we will have lines that provide the value of information, including providing the library which will store the input information. Then we create the menu to have the option the activity :

The library, the class, and the object :

The switch case to take the option ( The menu ) :

The function for “ The User “ object :
 

So the entire code for this object is : 

And the result for this program : 
Test case: 
            The input name for the reader is: Liem
            The ID number: 0456789
            The phone number of the reader is: 053466412
On the screen, we will have all the information:



LEAVE A COMMENT