• Every data in contact list has student ID (9- digit), name, and score after '#'. • The program accepts the ID. If ther
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
• Every data in contact list has student ID (9- digit), name, and score after '#'. • The program accepts the ID. If ther
• Every data in contact list has student ID (9- digit), name, and score after '#'. • The program accepts the ID. If there is ID in the contact matched, the program returns the name and score. If there is no ID matched, the program returns the error message and asks for another input. • Hint: - Use the template shown next page
1 2 3 4 5 6 7 8 9 10 11 12 13. 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 #include <iostream> using std::cout; using std::cin; using std::endl; #include <string> std::string; using using std::getline; int main() { const int max_names= 5; const int ID_length = 9; string contacts[max_names] = { "E12345678 Mickey Mouse# 5", "A88825252 Goofy#80", "E62757575 Woody#75", "E15151515 Snow White# 95", "C62096999 Simba#100" // maximum number of names in contacts // length of ID number }; // show the contacts cout << "***** *** << endl; for (int i = 0; i < max_names; i++) cout << contacts << endl; cout << "*** *** << endl; Your code... cout << endl; system("pause"); return 0;
Example: If the ID is matched, show the name and score \\Mac\Home\Documents\NCKU IPL\Co... E12345678 Mickey Mouse#5 A88825252 Goofy#80 E62757575 Woody#75 E15151515 Snow White#95 C62096999 Simba#100 Enter the ID: C62096999 The name is Simba and the score is 100 points Example: If the ID is not matched, show the error message and ask for another input \\Mac\Home\Documents\NCKU... E12345678 Mickey Mouse#5 A88825252 Goofy #80 E62757575 Woody#75 E15151515 Snow White# 95 C62096999 Simba#100 ****** Enter the ID: E1234 No ID is matched in contacts! Enter the ID:.