lundi 5 novembre 2018

Statement still displaying even it is not equal C++

I just really need a quick help :D This is only one part of my library management system I just wanna ask why is "Book number doesn't exist" is still displaying in my code? even if the input is not equal to the if statement If the user picks 1,2,3 the books will display but if the user input numbers that are not equal to 1,2,3 it will display "Book number doesn't exist" I'm still a nooby so please someone enlighten me thanks! :D Thanks!

Here's my code :D

'int size;
string bookss [4] = {"","History", "Math", "English" };
while (size!=0){
cout<<"List of Books: "<<endl;
cout<<"1. History \n2. Math \n3. English"<<endl;
cout<<"Enter how many books: ";
cin>>size;
if (size>3){
    cout<<"You can't borrow more than the quantity of books above"<<endl;
}else{
int books[size];
int ctr = 0;
while (ctr<=(size-1)){
    cout<<"Enter the book's number: ";
    cin>>books[ctr];
    ctr++;
if ((ctr!=1)&&( ctr!=2)&&(ctr!=3)){
    cout<<"Book number doesn't exist!";

}
}
cout<<"\n";
cout<<"You've borrowed: "<<endl;
ctr = 0;
while(ctr<=(size-1)){
    cout<<"-"<<bookss[books[ctr]]<<endl;
    ctr++;
}
}
}
}
`

Aucun commentaire:

Enregistrer un commentaire