In: Computer Science
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"
#include <iostream>
using namespace std;
int i=-1;
struct student
{
int id;
char name[50];
int nobook;
int book[100];
};
struct library
{
char name[50];
};
library l;
student s[10];
int student_details(int i)
{
s[i].id=i;
cout << "Enter name: ";
cin >> s[i].name;
cout << "no of books: ";
cin >> s[i].nobook;
cout << "Enter book ISBN : ";
for(int j=0;j<s[i].nobook;j++)
cin >> s[i].book[j];
return 0;
}
int librarian_details()
{
cout << "Enter name: ";
cin >> l.name;
for(int j=0;j<=i;j++)
{
cout<<j<<" "<<s[j].name<<"
borrowed "<<s[j].nobook<<"books"<<endl;
}
cout<<"Type student id for more info.\n" ;
int info;
cin>>info;
for(int k=0;k<s[info].nobook;k++)
{
cout<<s[info].book[k]<<endl;
}
return 0;
}
int main()
{
int choice;
while(1)
{
cout<<"Are you a student or a
librarian?\n";
cout<<"Hit 1 for student and
2 for librarian.\n";
cin>>choice;
switch(choice)
{
case
1:i+=1;
student_details(i);
break;
case
2:librarian_details();
break;
default:cout<<"wrong choice\n";
}
cout<<"Hit 1 to continue 0 to
end system\n";
int choice1;
cin>>choice1;
if(choice1==0)
{
exit(0);
}
}
return 0;
}