Question

In: Computer Science

C++: Write a student class for the library, which have the following: Username, password, Maximum number...

C++: Write a student class for the library, which have the following:

Username, password, Maximum number of copies that a student is allowed to keep(less than 5), maximum borrow periods(less than 30 days per book), list of copy(array)

cpp and h

Solutions

Expert Solution

//Here is the class containing for the stude nt in c++

class student{

     private:

            string username;

            string password;

            int no_of_copies;

            string copies[5]; //array for storing copies name borrowed by student

     public :

           student

           {

                   no_of_copies=1;

           }

           int checkUsernamePassword(string username,string password)

          {

                       if((this.username==username)&&(this.password==password))

                       {

                                    return 1;

                        }

                       else

                         {

                                   cout<<"Please Check username and password"<<endl;

                         }

          }

            void   IssueBook(string bookName)

           {

                          if(no_of_copies<5)

                           {

                                       no_of_copies;

                                      copies[no_of_copies]=bookName;

                           }

                           else

                            {

                                       cout<<"Your limit exceed please return any book "<<endl;

                             }

           }

           void returnBook(string bookName)

           {

                  for(int i=1;i<=no_of_copies;i++)

                  {

                                int j=0;

                                if(copies[i]==bookName)

                                {

                                       cout<<"Book returned"<<endl;

                                       j=i;

                                       while(j<=no_of_copies)

                                       {

                                                 copies[j]=copies[j+1];

                                                  j++;

                                        }

}                         

                  }

           }

           

};


Related Solutions

Write C++ code that prompts the user for a username and password (strings), and it calls...
Write C++ code that prompts the user for a username and password (strings), and it calls the login() function with the username and password as arguments. You may assume that username and password have been declared elsewhere. Your code should print error messages if login() generates an exception: LoginException: "Username not found or password incorrect" ServerException: "The login server is busy and you cannot log in" AccessException: "Your account is forbidden from logging into this server" Any other exception: "Unknown...
Write C++ code that prompts the user for a username and password (strings), and it calls...
Write C++ code that prompts the user for a username and password (strings), and it calls the login() function with the username and password as arguments. You may assume that username and password have been declared elsewhere. Use virtual functions, pure virtual functions, templates, and exceptions wherever possible. Please explain the code. Your code should print error messages if login() generates an exception: LoginException: "Username not found or password incorrect" ServerException: "The login server is busy and you cannot log...
Write the following queries using the schema below Class (Number, Department, Term, Title) Student (Username, FirstName,...
Write the following queries using the schema below Class (Number, Department, Term, Title) Student (Username, FirstName, LastName, Year) Takes (Username, Department, Number, Term, Grade) [clarification] In Student, Year is an integer. A student can be a 2nd year student. In that case, Year value would be 2. For the Takes relation: ·         Grade is NA for current semester students ·         Username is foreign key to Student ·         (Department, Number, Term) is foreign key to Class a)       Write an SQL query that returns the Term...
-Write in C++ -Use Char library functions Write a function that accepts a string representing password...
-Write in C++ -Use Char library functions Write a function that accepts a string representing password and determines whether the string is a valid password. A valid password as the following properties: 1. At least 8 characters long 2. Has at least one upper case letter 3. Has at least one lower case letter 4. Has at least one digit 5. Has at least on special character
Write a C program for a library automation which gets the ISBN number, name, author and...
Write a C program for a library automation which gets the ISBN number, name, author and publication year of the books in the library. The status will be filled by the program as follows: if publication year before 1985 the status is reference else status is available. The information about the books should be stored inside a linked list. The program should have a menu and the user inserts, displays, and deletes the elements from the menu by selecting options....
Question3: Consider you have the following data for some user accounts: [6 marks] Username Password User1...
Question3: Consider you have the following data for some user accounts: [6 marks] Username Password User1 101010 User2 112121 User3 211211 User4 312132 1. Write a function called validate which takes 2 arguments: a dictionary, a username, and a password. The function should do the following: [3 marks] Find the given username in the dictionary and compare the given password with the one that belongs to that username in the dictionary. Return true if password is correct and false if...
Write a C++ program that checks if the password is correct. The password is a 4-digit...
Write a C++ program that checks if the password is correct. The password is a 4-digit number combination. The program repeats to ask the password until the password is correct or you enter -1 to exit. Input: The password is set to ‘1123’. A user input the password to proceed, or -1 to exit. Sample Output: The program should display the following output. (The red text is a user input.) Test case 1: when you enter the correct password. Enter...
using java Define a class Library based on the following specifications: a. A library can have...
using java Define a class Library based on the following specifications: a. A library can have multiple books. Decide on the best possible data structure to store books. b. A library has a name. c. A library has an address. Define a 2-argument constructor for the Library class. Decide on the arguments needed for this constructor. e. Define a method that can add new books to the library. f. Define a method that allows a book to be borrowed (checked...
The following times between keystrokes were recorded when a user typed the username and password: .23,...
The following times between keystrokes were recorded when a user typed the username and password: .23, .21, .27, .35, .33, .31, .34, .28, .20, .35, .31, .16, .16, .29, .39, .40, .35, .26 seconds. Let’s construct a 99% confidence interval for the mean time between keystrokes assuming Normal distribution of these times.
Write a C program that calculates a student grade in the C Programming Class. Ask the...
Write a C program that calculates a student grade in the C Programming Class. Ask the user to enter the grades for each one of the assignments completed in class: Quiz #1 - 25 points Quiz #2 - 50 points Quiz #3 - 30 points Project #1 - 100 points Project #2 - 100 points Final Test - 100 points The total of the quizzes count for a 30% of the total grade, the total of the projects counts for...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT