Knowee
Questions
Features
Study Tools

Write a program to create a bank customer information using array of structures, nested structures and functions.First structure should hold the following information: Customer personal details: Name, Gender, Account Number, DOB; Second structure should hold the following information: Customer account details: Type of account, opening balance, closing balance

Question

Write a program to create a bank customer information using array of structures, nested structures and functions.First structure should hold the following information: Customer personal details: Name, Gender, Account Number, DOB; Second structure should hold the following information: Customer account details: Type of account, opening balance, closing balance

🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure, here is a simple program in C++ that uses array of structures and nested structures to hold bank customer information.

#include<iostream>
#include<string>
using namespace std;

// First structure for personal details
struct PersonalDetails {
    string name;
    string gender;
    int accountNumber;
    string dob;
};

// Second structure for account details
struct AccountDetails {
    string accountType;
    double openingBalance;
    double closingBalance;
};

// Main structure for customer
struct Customer {
    PersonalDetails personal;
    AccountDetails account;
};

// Function to create a new customer
Customer createCustomer(string name, string gender, int accountNumber, string dob, string accountType, double openingBalance, double closingBalance) {
    Customer newCustomer;
    newCustomer.personal.name = name;
    newCustomer.personal.gender = gender;
    newCustomer.personal.accountNumber = accountNumber;
    newCustomer.personal.dob = dob;
    newCustomer.account.accountType = accountType;
    newCustomer.account.openingBalance = openingBalance;
    newCustomer.account.closingBalance = closingBalance;
    return newCustomer;
}

// Function to display customer information
void displayCustomer(Customer customer) {
    cout << "Name: " << customer.personal.name << endl;
    cout << "Gender: " << customer.personal.gender << endl;
    cout << "Account Number: " << customer.personal.accountNumber << endl;
    cout << "DOB: " << customer.personal.dob << endl;
    cout << "Account Type: " << customer.account.accountType << endl;
    cout << "Opening Balance: " << customer.account.openingBalance << endl;
    cout << "Closing Balance: " << customer.account.closingBalance << endl;
}

int main() {
    // Create an array of customers
    Customer customers[2];
    customers[0] = createCustomer("John Doe", "Male", 123456, "01-01-1990", "Savings", 1000.0, 2000.0);
    customers[1] = createCustomer("Jane Doe", "Female", 654321, "02-02-1992", "Current", 2000.0, 3000.0);

    // Display customer information
    for(int i = 0; i < 2; i++) {
        displayCustomer(customers[i]);
    }

    return 0;
}

This program first defines the structures PersonalDetails and AccountDetails for holding personal and account details of a customer respectively. Then it defines the main Customer structure which nests the previous two structures.

The createCustomer function is used to create a new customer with the given details and the displayCustomer function is used to display the details of a customer.

In the main function, an array of Customer structures is created and two customers are added to it. Then the details of all customers in the array are displayed.

This problem has been solved

Similar Questions

Write a java program to create a bank account with Name of the account holder, type of account(savings or  current), Account number and Balance amount in the account. Also, create 5 customers for the class Bank_account using array of objects. Access the customers to perform credit, debit and display of balance.Input 1:Enter the customers:ReenaSavings1231000RobinCurrent4562000PraveenSavings7893000SherinCurrent2342500DeenaSavings5672000Enter choice:1. Credit2. Debit Output :ReenaSavings1232000

Complete the function get_bank_data(). The function reads tot_customers  and  an array to store customer details(cust_id, cust_acc_num, cust_name, amount_in_account) in a struture for each customer  at runtime.  Read the customer details at runtime and store it in the array and return the array . The structure to store cust_id,cust_acc_num,cust_name,amount_in_account is predefined, refer it for your task completion.Input Format:Accept the count of total customers - which is provided inside main()Read customer id, customer account number , customer name and amount in account as line separatedand repeat it for total count of customers.Output Format:Returning the the read input from the function to main i

Consider a scenario where you need to manage records of employees in a company. Create aprogram in C that utilizes structures to handle employee information. The program shouldperform the following tasks:a. Define a structure named Employee with the following attributes:Employee ID (integer)Employee Name (string)Department (string)Salary (float)b. Create an array of structures to store information for a maximum of 5 employees.c. Display the information of the employees.

Create  a class for bank customer : Account number, phone number , name, Gender ( M/F). Create user name and password for online banking using following constraints.User name will  be three upper case letters of bank name followed by last three digit of account number then last  two character of name( upper case).For bank name  : if account number starts with ‘2’ then Indian bank, if it starts with ‘3’ then state bankPass word id middle four digit of phone number preceded by three characters “INB” for “Indian  bank and “ STB” for state bank , succeeded by “MA” for male or “ “FE” for female.Account number should be of five digit only ,else print “ Invalid Account Number”.Create three objects and display user name , password and how many accounts in  each bank.Example :Input252349034493459MadhavMOutputUser name :  IND234AVPass word :  INB4493MAINDIAN BANK:1STATE BANK:0

You are required to implement a simple C++ program for managing a bank account. The program should include a class BankAccount with private attributes for account number, account holder name, and account balance.The BankAccount class should have the following:A parameterized constructor to initialize the account number, account holder name, and account balance.A friend function displayAccountInfo that takes a BankAccount object as an argument and displays the account information (account number, account holder name, and account balance).Additionally, the program should check if the account balance is greater than Rs.10,000 and display whether the account holder is eligible for a credit card.Testcase1:Sample Input:12345   // account numberJohn Doe  // name15000   // balanceSample Output:12345John Doe15000Yes Testcase2:Sample Input:98765   // account numberVirat Kohli  // name8000   // balanceSample Output:98765Virat Kohli8000No

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.