Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Create a new file named: CustomerDB. t x t . A customer data file contains a list o f customers ( o n e per

Create a new file named: CustomerDB.txt. A customer data file contains a list of customers (one per line), each customer consisting of a unique customer id followed by a first and last name.
42 Mike Jones
16Al Garcia
27 Sarah Lee
12 Stan Lee
99 Amy Hernandez
Ask the user to enter the idto find.
As you read from the file, search for the id
If found, output the customer's info as Customer id#: Last, First
If not found, output Not Found
what I have:
#include ??std::ifstream
#include ??std::cin, std::cout
#include ??std::string
int main(){
std::string idToFind;??Using string for idin cases of both numbers and letters, like M47
std::cout << "Enter ID: ";
std::cin >> idToFind;
std::string dbId;
std::string dbFirstName;
std::string dbLastName;
std::ifstream fin;
fin.open("CustomerDB.txt");
if(!fin){
std::cout <<"
Error opening file for reading
";
return -1;
}
while(! fin.fail()){
}
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions