0% found this document useful (0 votes)
7 views15 pages

CUSTOMER

The document outlines the design and functionality of a customer interface for a car rental system, detailing processes for adding, searching, reporting, and counting customers. It includes algorithms and C++ code snippets for managing customer data, such as inputting customer information and retrieving it from a file. The system aims to simplify the rental process for users by providing an accessible online platform and efficient data management.

Uploaded by

nurinjazlina4408
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views15 pages

CUSTOMER

The document outlines the design and functionality of a customer interface for a car rental system, detailing processes for adding, searching, reporting, and counting customers. It includes algorithms and C++ code snippets for managing customer data, such as inputting customer information and retrieving it from a file. The system aims to simplify the rental process for users by providing an accessible online platform and efficient data management.

Uploaded by

nurinjazlina4408
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

2.

1) Customer Interface

A rental car system

A car rental system's customer interface is designed to facilitate easy interaction with rental
services. It enables customers to check vehicle availability and book rentals for specific
dates. This system features an online reservation platform accessible through a dedicated
booking website or the rental company's own site. It ensures a straightforward booking
process, gathering necessary customer details like name, contact information, and
preferences. To improve convenience, it simplifies the process of checking in and out of
vehicles.

2.1.1) Full Interface

a) Analysis

Input: customerID, name, address, phoneNumber

Output: customerID, name, address, phoneNumber

Process: Open File

b) Algorithm

Begin newCust

Declare customerID, name, address, phoneNumber as string

Open file customerData.txt in append mode as customerFile

If customerFile is not open

Display Error: Unable to open file customerData.txt

Return

Display Enter Customer ID:

Read customerID

Display Enter Name:

Read name
Display Enter Address:

Read address

Display Enter Phone Number:

Read phoneNumber

Write customerID to customerFile

Write name to customerFile

Write address to customerFile

Write phoneNumber to customerFile

Close customerFile

Display Customer added successfully.

Display a newline

End newCust

c) Coding c++

void readCustData();

void newCustomer() {

ofstream customerFile("customerData.txt", ios::app);

if (!customerFile.is_open()) {

cerr << "Error: Unable to open file customerData.txt" << endl;

return;

string customerID, name, address, phoneNumber;


cout << "Enter Customer ID: ";

getline(cin, customerID);

cout << "Enter Name: ";

getline(cin, name);

cout << "Enter Address: ";

getline(cin, address);

cout << "Enter Phone Number: ";

getline(cin, phoneNumber);

customerFile << customerID << endl;

customerFile << name << endl;

customerFile << address << endl;

customerFile << phoneNumber << endl;

customerFile.close();

cout << "Customer added successfully." << endl;

cout << endl;

d) Flowchart
2.1.2) Search Customer
a) Analysis

Input: searchID

Output: Customer Found!, customerID, name, Adress, Phone Number

Process: Open File

b) Algorithm

Begin searchCustomer

Open file customerData.txt in read mode as customerFile

If customerFile is not open

Display Error: Unable to open file customerData.txt

Return

Declare string variable searchID

Display Enter Customer ID to Search:

Read searchID

Declare string variable line

Declare bool variable found = false

While not end of customerFile

Read line from customerFile into customerID

Read line from customerFile into name

If customerID equals searchID

found = true
Display Customer Found!

Display Customer ID: + customerID

Display Name: + name

Read line from customerFile into address

Display Address: + address

Read line from customerFile into phoneNumber

Display Phone Number: + phoneNumber

Display ---------------------------

Else

Skip next two lines from customerFile

If found is false

Display No customers found with the ID + searchID

Close customerFile

End searchCustomer

c) Coding c++

void readCustData();

void newCustomer() {
ofstream customerFile("customerData.txt", ios::app);

if (!customerFile.is_open()) {

cerr << "Error: Unable to open file customerData.txt" << endl;

return;

string customerID, name, address, phoneNumber;

cout << "Enter Customer ID: ";

getline(cin, customerID);

cout << "Enter Name: ";

getline(cin, name);

cout << "Enter Address: ";

getline(cin, address);

cout << "Enter Phone Number: ";

getline(cin, phoneNumber);

customerFile << customerID << endl;

customerFile << name << endl;

customerFile << address << endl;

customerFile << phoneNumber << endl;

customerFile.close();

cout << "Customer added successfully." << endl;

cout << endl;

}
d) Flowchart
2.1.3) Report Customer
a) Analysis

Input: customerFile

Output: customerID, Name, Adress, Phone Number

Process: Open File

b) Algorithm

Begin reportCustomer

Open file customerData.txt in read mode as customerFile

If customerFile is not open

Display Error: Unable to open file customerData.txt

Return

Declare string variable line

While not end of customerFile

Read line from customerFile into customerID

Display Customer ID: + customerID

Read line from customerFile into name

Display Name: + name

Read line from customerFile into address

Display Address: + address

Read line from customerFile into phoneNumber


Display Phone Number: + phoneNumber

Display ---------------------------

Close customerFile

End reportCustomer

c) Coding c++

void reportCustomer() {

ifstream customerFile("customerData.txt");

if (!customerFile.is_open()) {

cerr << "Error: Unable to open file customerData.txt" << endl;

return;

string line;

while (getline(customerFile, line)) {

cout << "Customer ID: " << line << endl;

getline(customerFile, line);

cout << "Name: " << line << endl;

getline(customerFile, line);

cout << "Address: " << line << endl;

getline(customerFile, line);

cout << "Phone Number: " << line << endl;


cout << "---------------------------" << endl;

customerFile.close();

d) Flowchart
2.1.4) Customer Amount
a) Analysis

Input: customerAmount

Output: totalCustomers

Process: Declare integer

b) Algorithm

Begin customerAmount

Declare int variable totalCustomers

Set totalCustomers = Call calculateTotalCustomers

Display "Total Number of Customers: " + totalCustomers

End customerAmount

c) Coding c++

void customerAmount() {

int totalCustomers = calculateTotalCustomers();

cout << "Total Number of Customers: " << totalCustomers << endl;

d) Flowchart

You might also like