Question: else if (choice == 3) { int num; string option; string add = y ; cout < < endl ; string choiceAuthor = y ;

else if (choice == "3")

{

int num;

string option;

string add = "y";

cout << endl;

string choiceAuthor = "y";

while (choiceAuthor == "y") {

cout << "\t\tWould you like to:" << endl;

cout << "\t\t1- Change current Authors" << endl;

cout << "\t\t2- Add an Author" << endl;

cout<<endl;

cout << "\t\tSelect your choice <1-2>" << endl;

cout << "\t\tChoice: ";

getline(cin, option);

if (option == "1")//change current Authors name {

for (int j = 0; j < libDB[i].authors.size(); j++)

{

cout<<endl;

cout<<"\t\t-------------------------------------------"<<endl;

cout << "\t\t\t Author " << j + 1 << endl;

cout<<"\t\t-------------------------------------------"<<endl;

cout << "\t\tFirst name : " << libDB[i].authors[j].fname << endl;

cout << "\t\tLast name : " << libDB[i].authors[j].lname << endl;

}

cout << endl;

cout << "\t\tWhich Author's name would you like to change?" << endl;

cout << "\t\tChoice: ";

cout<<endl;

cin >> num;//the user will select

while (num <= 0 || num > libDB[i].authors.size())//must be greater than 0 and less or equal to

{//this is if the user select the invalid number

cin.clear();

cin.ignore(100, ' ');

cout << "\t\tInvalid Choice" << endl;

cout << "\t\tPlease try a valid number: ";

cin >> num;

}

cin.ignore(100, ' ');

cout << "\t\tFirst name: ";

getline(cin, libDB[i].authors[num - 1].fname);

cout << "\t\tLast name : ";

getline(cin, libDB[i].authors[num - 1].lname);

choiceAuthor = "n";

cout<<endl << "\t\t\t**Modified successfully**" << endl;

}

else if (option == "2")// this option is for adding another Authors name

{

while (add == "y" || add == "Y")

{

cout<<endl;

cout << "\t\tAuthor's First name: ";

getline(cin, temp_n.fname);

cout << "\t\tAuthors's Last name: ";

getline(cin, temp_n.lname);

libDB[i].authors.push_back(temp_n);

cout << endl;

cout << "\t\tWould you like to add another Author's name?" << endl;

cout << "\t\t\tPress (y) for yes " <<endl;

cout << "\t\t\tPress (n) for no " <<endl;

cout << "\t\t\tChoice: ";

getline(cin, add);

}

choiceAuthor = "n";

cout << "\t\t\t**Modified successfully**" << endl;

}

else

{

cout << "\t\tInvalid Choice" << endl;

cout << "\t\tPlease enter a valid input" << endl;

}

}

}

what is (choiceAuthor = "n";)

what does it mean and why is it put there amd can you explain the code line by line too please thank you so much

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!