1) IPO Table (using Microsoft Word) 2) Pseudocode (Word) [A working Flowchart cr
ID: 3735246 • Letter: 1
Question
1) IPO Table (using Microsoft Word) 2) Pseudocode (Word) [A working Flowchart created using Raptor (Submit the actual Raptor file *Optional* 3) UML Diagram for the Class (Word) Your project must include: At least 1 Selection Structure . At least 1 Loop Structure At least 1 Method At least 1 Array At least 1 Class Project Scenario: The Yummy Chocolates confectionery company requires a program to keep track of their customers. They want to keep track of each customer's number, name, address (street, city, state and postcode) and account balance. They want their application to have a simple interface of the following options: Option A' (add), 'D' (delete), ‘U, (update), 'L' (List) and 'Q' (Quit). Here is how the menu options should work: i. If the transaction record is an 'Add', new customer information should be added ii. If the transaction record is a 'Delete', a customer information is deleted from record iii. If the transaction record is an 'Update', a customerExplanation / Answer
#include<iostream>
#include<string>
#include<stdlib.h>
#define MAX 100
using namespace std;
// class Address definition
class Address
{
public:
// Data member to store data
string street;
string city;
string state;
int postcode;
// Default constructor
Address()
{
street = "";
city = "";
state = "";
postcode = 0;
}// End of default constructor
};// End of class
// class Customer definition
class Customer
{
// Data member to store data
int number;
string name;
// Declares an object of Address class using deligation mechanism
Address add;
double balance;
public:
// Default constructor
Customer()
{
number = 0;
name = "";
balance = 0.0;
}// End of default constructor
// Parameterized constructor
Customer(int no, string na, Address ad, double ba)
{
number = no;
name = na;
add = ad;
balance = ba;
}// End of parameterized constructor
// Function to return customer number
int getCustomerNumber()
{
return number;
}// End of function
// Function to set customer name
void setName(string na)
{
name = na;
}// End of function
// Function to set balance
void setBalance(double ba)
{
balance = ba;
}// End of function
// Function to set address
void setAddress(Address ad)
{
add = ad;
}// End of function
// Function to display customer information
void displayCustomer()
{
cout<<" Customer Number: "<<number;
cout<<" Customer Name: "<<name;
cout<<" Customer Address: ";
cout<<" Street: "<<add.street;
cout<<" City: "<<add.city;
cout<<" State: "<<add.state;
cout<<" Postcode: "<<add.postcode;
cout<<" Balance: "<<balance;
}// End of function
// Function to accept customer information
void acceptCustomer()
{
cout<<" Enter Customer Number: ";
cin>>number;
cout<<" Enter Customer Name: ";
cin>>name;
// Accepts class Address information
cout<<" Enter Customer Address: ";
cout<<" Enter Street: ";
cin>>add.street;
cout<<" Enter City: ";
cin>>add.city;
cout<<" Enter State: ";
cin>>add.state;
cout<<" Enter Postcode: ";
cin>>add.postcode;
cout<<" Enter Balance: ";
cin>>balance;
}// End of function
};// End of class
// Function to display main menu choice, accept choice, and return choice
char menu()
{
// To store user choice
char choice;
// Display choice
cout<<" A - Add Customer";
cout<<" D - Delete Customer";
cout<<" U - Update Customer";
cout<<" L - List Customers";
cout<<" Q - Quit";
// Accepts user choice
cout<<" Enter your choice: ";
cin>>choice;
// Return choice
return choice;
}// End of function
// Function to display update menu choice, accept choice, and return choice
int updateMenu()
{
// To store user choice
int choice;
// Display choice
cout<<" 1 Update Name";
cout<<" 2 Update Address";
cout<<" 3 Update Balance";
// Accepts user choice
cout<<" Enter your choice: ";
cin>>choice;
// Return choice
return choice;
}// End of function
// Function to search a customer number if found returns index position otherwise returns -1
int searchCustomer(Customer c[], int len, int cusNo)
{
// Initializes index to -1 for not found
int index = -1;
// Loops till end of the record
for(int x = 0; x < len; x++)
{
// Checks if the current customer number is equals parameter customer number
if(c[x].getCustomerNumber() == cusNo)
{
// Set the counter value as index position
index = x;
// Come out of the loop
break;
}// End of if condition
}// End of for loop
// Return the index position
return index;
}// End of function
// Function to delete a customer
void deleteCustomer(Customer c[], int len, int index)
{
// Loops till end of the record
for(int x = index; x < len; x++)
// Sifts objects one position left
c[x] = c[x + 1];
}// End of function
// Function to update customer record
void updateCustomer(Customer c[], int index, int typeUpdate)
{
// To store name entered by the use
string name;
// To store balance entered by the user
double bal;
// Address object declared to store the address entered by the user
Address ad;
// Checks the type of updated option selected by the user
switch(typeUpdate)
{
// To update name
case 1:
// Accepts name
cout<<" Enter name to update: ";
cin>>name;
// Calls the method to set the name of the specified index position of the customer array
c[index].setName(name);
break;
// To update address
case 2:
// Accepts address information
cout<<" Enter Customer Address: ";
cout<<" Enter Street: ";
cin>>ad.street;
cout<<" Enter City: ";
cin>>ad.city;
cout<<" Enter State: ";
cin>>ad.state;
cout<<" Enter Postcode: ";
cin>>ad.postcode;
// Calls the method to set the address of the specified index position of the customer array
c[index].setAddress(ad);
break;
// To update balance
case 3:
// Accepts balance
cout<<" Enter balance: ";
cin>>bal;
// Calls the method to set the balance of the specified index position of the customer array
c[index].setBalance(bal);
// For invalid choice selected by the user
default:
cout<<" Invalid Update Choice!";
}// End of switch case
}// End of function
// main function definition
int main()
{
// Customer array declared
Customer customerArray[100];
// Customer object declared
Customer c;
// Current customer counter
int counter = 0;
// To store customer number entered by the user
int cusNo;
// To store the index position returned by the function searchCustomer()
int index;
// To store the choice selected by the user for update menu
int typeUpdate;
// Loops till user choice is not 'Q' or 'q'
do
{
// Calls the main menu and checks the return choice selected by the user
switch(menu())
{
case 'A':
case 'a':
// Calls the function to accept customer information
c.acceptCustomer();
cusNo = c.getCustomerNumber();
// Calls the function to search the customer number in customer record
index = searchCustomer(customerArray, counter, cusNo);
// Checks if the index value is not -1 record found
if(index != -1)
cout<<" Invalid addition, customer already exist.";
// Otherwise, add the record not found
else
{
// Adds the customer to customer array
customerArray[counter] = c;
// Increase the current customer count
counter++;
cout<<" Record successfully added.";
}// End of if condition
break;
case 'D':
case 'd':
// Accepts an account number from the user
cout<<" Enter a customer number to delete: ";
cin>>cusNo;
// Calls the function to search the customer number in customer record
index = searchCustomer(customerArray, counter, cusNo);
// Checks if the index value is not -1 record found
if(index != -1)
{
// Calls the function to delete the record
deleteCustomer(customerArray, counter, index);
// Decrease the current customer counter by one
counter--;
cout<<" Record successfully deleted.";
}// End of if condition
// Otherwise, display error message record not found
else
cout<<" Invalid deletion, customer not on file.";
break;
case 'U':
case 'u':
// Accepts an account number from the user
cout<<" Enter a customer number to update: ";
cin>>cusNo;
// Calls the function to search the customer number in customer record
index = searchCustomer(customerArray, counter, cusNo);
// Checks if the index value is not -1 record found
if(index != -1)
{
// Calls the function to update the record based on the update option selected
// updateMenu() to call the updated menu selection
updateCustomer(customerArray, index, updateMenu());
cout<<" Record successfully updated.";
}// End of if condition
// Otherwise, display error message record not found
else
cout<<" Invalid update, customer not on file.";
break;
case 'L':
case 'l':
// Loops till end of the record
for(int x = 0; x < counter; x++)
// Calls the function to display customer information
customerArray[x].displayCustomer();
break;
case 'Q':
case 'q':
exit(0);
default:
cout<<" Invalid selection!";
}// End of switch case
}while(1); // End of do - while loop
}// End of main function
Sample Output 1:
A - Add Customer
D - Delete Customer
U - Update Customer
L - List Customers
Q - Quit
Enter your choice: a
Enter Customer Number: 111
Enter Customer Name: Pyari
Enter Customer Address:
Enter Street: bam
Enter City: bam
Enter State: Ori
Enter Postcode: 123233
Enter Balance: 1000
Record successfully added.
A - Add Customer
D - Delete Customer
U - Update Customer
L - List Customers
Q - Quit
Enter your choice: A
Enter Customer Number: 111
Enter Customer Name: Sarita
Enter Customer Address:
Enter Street: Amod
Enter City: RGDA
Enter State: Ori
Enter Postcode: 123231
Enter Balance: 1900
Invalid addition, customer already exist.
A - Add Customer
D - Delete Customer
U - Update Customer
L - List Customers
Q - Quit
Enter your choice: a
Enter Customer Number: 222
Enter Customer Name: Mohan
Enter Customer Address:
Enter Street: Ban
Enter City: BBSR
Enter State: Ori
Enter Postcode: 123222
Enter Balance: 2000
Record successfully added.
A - Add Customer
D - Delete Customer
U - Update Customer
L - List Customers
Q - Quit
Enter your choice: a
Enter Customer Number: 333
Enter Customer Name: Sahu
Enter Customer Address:
Enter Street: Ram
Enter City: RKL
Enter State: Ori
Enter Postcode: 123221
Enter Balance: 1500
Record successfully added.
A - Add Customer
D - Delete Customer
U - Update Customer
L - List Customers
Q - Quit
Enter your choice: l
Customer Number: 111
Customer Name: Pyari
Customer Address:
Street: bam
City: bam
State: Ori
Postcode: 12323
Balance: 1000
Customer Number: 222
Customer Name: Mohan
Customer Address:
Street: Ban
City: BBSR
State: Ori
Postcode: 123222
Balance: 2000
Customer Number: 333
Customer Name: Sahu
Customer Address:
Street: Ram
City: RKL
State: Ori
Postcode: 123221
Balance: 1500
A - Add Customer
D - Delete Customer
U - Update Customer
L - List Customers
Q - Quit
Enter your choice: D
Enter a customer number to delete: 555
Invalid deletion, customer not on file.
A - Add Customer
D - Delete Customer
U - Update Customer
L - List Customers
Q - Quit
Enter your choice: d
Enter a customer number to delete: 222
Record successfully deleted.
A - Add Customer
D - Delete Customer
U - Update Customer
L - List Customers
Q - Quit
Enter your choice: l
Customer Number: 111
Customer Name: Pyari
Customer Address:
Street: bam
City: bam
State: Ori
Postcode: 12323
Balance: 1000
Customer Number: 333
Customer Name: Sahu
Customer Address:
Street: Ram
City: RKL
State: Ori
Postcode: 123221
Balance: 1500
A - Add Customer
D - Delete Customer
U - Update Customer
L - List Customers
Q - Quit
Enter your choice: U
Enter a customer number to update: 222
Invalid update, customer not on file.
A - Add Customer
D - Delete Customer
U - Update Customer
L - List Customers
Q - Quit
Enter your choice: u
Enter a customer number to update: 333
1 Update Name
2 Update Address
3 Update Balance
Enter your choice: 1
Enter name to update: Sasmita
Record successfully updated.
A - Add Customer
D - Delete Customer
U - Update Customer
L - List Customers
Q - Quit
Enter your choice: l
Customer Number: 111
Customer Name: Pyari
Customer Address:
Street: bam
City: bam
State: Ori
Postcode: 12323
Balance: 1000
Customer Number: 333
Customer Name: Sasmita
Customer Address:
Street: Ram
City: RKL
State: Ori
Postcode: 123221
Balance: 1500
A - Add Customer
D - Delete Customer
U - Update Customer
L - List Customers
Q - Quit
Enter your choice: u
Enter a customer number to update: 111
1 Update Name
2 Update Address
3 Update Balance
Enter your choice: 2
Enter Customer Address:
Enter Street: BankColony
Enter City: Berhampur
Enter State: Orissa
Enter Postcode: 760003
Record successfully updated.
A - Add Customer
D - Delete Customer
U - Update Customer
L - List Customers
Q - Quit
Enter your choice: l
Customer Number: 111
Customer Name: Pyari
Customer Address:
Street: BankColony
City: Berhampur
State: Orissa
Postcode: 760003
Balance: 1000
Customer Number: 333
Customer Name: Sasmita
Customer Address:
Street: Ram
City: RKL
State: Ori
Postcode: 123221
Balance: 1500
A - Add Customer
D - Delete Customer
U - Update Customer
L - List Customers
Q - Quit
Enter your choice: u
Enter a customer number to update: 333
1 Update Name
2 Update Address
3 Update Balance
Enter your choice: 3
Enter balance: 7400
Invalid Update Choice!
Record successfully updated.
A - Add Customer
D - Delete Customer
U - Update Customer
L - List Customers
Q - Quit
Enter your choice: l
Customer Number: 111
Customer Name: Pyari
Customer Address:
Street: BankColony
City: Berhampur
State: Orissa
Postcode: 760003
Balance: 1000
Customer Number: 333
Customer Name: Sasmita
Customer Address:
Street: Ram
City: RKL
State: Ori
Postcode: 123221
Balance: 7400
A - Add Customer
D - Delete Customer
U - Update Customer
L - List Customers
Q - Quit
Enter your choice: q
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.