The following code DOES NOT STOP to request the value for lname or ID. What line of code could you include to ensure the user can enter the requested integer and line of text? Modify the code below. Place the line of code in the correct place to fix the problem. Note: remember the file read pointer. int choice; string lname, Id; cout << “Welcome to the student record search system” << endl; cout << "Please enter 1 to search by last name or 2 to search by ID " << endl; cin >> choice; if (choice == 1) { cout << “Please enter the last name “ << endl; getline(cin, lname); } else { cout << "Please enter the ID “ << endl; getline(cin, Id); }

Programming with Microsoft Visual Basic 2017
8th Edition
ISBN:9781337102124
Author:Diane Zak
Publisher:Diane Zak
Chapter8: Arrays
Section: Chapter Questions
Problem 7E
icon
Related questions
Question
  1. The following code DOES NOT STOP to request the value for lname or ID. What line of code could you include to ensure the user can enter the requested integer and line of text?  Modify the code below.   Place the line of code in the correct place to fix the problem.  Note:  remember the file read pointer.

 

  int choice;

  string lname, Id;

 

  cout  << “Welcome to the student record search system” << endl;

  cout << "Please enter 1 to search by last name  or  2 to search by ID " << endl;

 

  cin >> choice;

 

   if (choice == 1)

  {

     cout << “Please enter the last name “ << endl;

     getline(cin, lname);

 }

  else

  {

    cout << "Please enter the ID “ << endl;

    getline(cin,  Id);

 }

 

 

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr