In: Computer Science
I beg of anyone to answer this :)
Create a system which ends when the user wants it to. After a user has used this system, there is an option of another user using it. The system should ask whether you want to continue or not. Below is a sample of the input/output system.
Are you a student or a librarian?
Hit 1 for student and 2 for librarian.
$1
Enter Name: $William
How many books do you want to take?
$4
What books do you want to take?
Enter book ISBN no(Ex: 242424) // Let's assume we have a 6 digit
ISBN number for this project. Put any number to test //your
system.
$454092
$535212
$676685
$128976
William borrowed 4 books.
Hit 1 to continue 0 to end system
$1
Are you a student or a librarian?
Hit 1 for student and 2 for librarian.
$2
Enter Name: $Miss Benny
0 Lisa borrowed 1 books //format: student_id Student_name
"borrowed" number_of_books "books"
1 William borrowed 4 books
Type student id for more info.
$ 0
Lisa borrowed 1 books
235633
Hit 1 to continue 0 to end system
$0
//There needs to be an array for studentid, student name, isbn index start #, isbn index end #, and libarian name
//This is also C++,
//If you need further information please specify in the comments and I will edit the problem as needed. I need this information ASAP please.
//The $ represents inputs made by the "user"
Please find below c++ code .
Here use structure for store student details. Also use array for store book details and student details.
#include<iostream>
using namespace std;
//structure for student
struct Student
{
string name; //name of student
int id; // id of student
int book_no; // total number of book
int book_id[10]; //list of book
}student[10];
int main(){
int sorl,ch;
int id=0;
int scount=0;
string lname;
int studid;
do{
cout<<"Are you a student or a librarian?\nHit 1 for student and 2 for librarian.\n$";
cin>>sorl; //read student or librarian
if(sorl==1){
Student stud; // create variable of student
stud.id=id; //set id for student
cout<<"Enter Name: $";
cin>>stud.name; // read name of student
cout<<"How many books do you want to take?\n$";
cin>>stud.book_no; // read number of book
cout<<"What books do you want to take?\nEnter book ISBN no(Ex: 242424)\n";
for(int i=0;i<stud.book_no;i++){ //read isbn of all books
cout<<"$";
cin>>stud.book_id[i];
}
student[scount]=stud; // assign student object to array
cout<<stud.name<<" borrowed "<<stud.book_no<<" books"<<endl; // display details
scount++; // increment count
id++; //incement id
}
// case of librarian
else{
cout<<"Enter Name: $";
cin>>lname; //read name
// display all student details
for(int i=0;i<scount;i++){
cout<<student[i].id<<" "<<student[i].name<<" "<<"borrowed "<<student[i].book_no<<" books"<<endl;
}
//display details of specific student
cout<<"Type student id for more info.\n$";
cin>>studid;
for(int i=0;i<scount;i++){
if(student[i].id==studid){
cout<<student[i].id<<" "<<student[i].name<<" "<<"borrowed "<<student[i].book_no<<" books"<<endl;
for(int j=0;j<student[i].book_no;j++)
cout<<student[i].book_id[j]<<endl;
}
}
}
cout<<"Hit 1 to continue 0 to end system \n$";
cin>>ch;
}while(ch!=0);
return 0;
}
output