Code:#include <iostream> #include <fstream> #include <string> using namespace std; int main() { string lastName; double number, target, parkingSticker; const double SENTINEL = 000000; cout << "Please enter a parking sticker number (enter 000000 to exit): " << endl; cin >> target; while (target != SENTINEL) { string findName(int foundName) { bool found = false; string foundName = "NOT FOUND"; ifstream input("HWK5.txt"); if (input.is_open()) { input >> lastName >> parkingSticker; while (! input.eof() && !found) { if (target == parkingSticker) { foundName = lastName; found = true; } input >> lastName >> parkingSticker; } } input.close(); return foundName; } } if (foundName != "NOT FOUND") cout << "The parking sticker number belongs to " << lastName << endl; else cout << "This parking sticker is not on file. Try again." << endl; system("pause"); return 0; }
Still many problems.![]()




Reply With Quote