I am doing this program for a cs class. I am trying to create menu based system that will allow the user to input the number that corresponds to the option they want to choose. Then based on that option they will input their customer id (this is a banking type question and all the customer have a .dat file that will be read and written to) then display the info from the file to the console. I am getting a message that says my file that I am trying to open is undefined. I was wondering if someone could help me resolve this or if there is a good example I could look at. the code is not finished as I am tackling it part by part

/*
Team#: 8
Team Member-1: Joe Mendoza Member’s Contribution (in %) 50%
Team Member-2: Omear Gonzalez Member’s Contribution (in %) 50%
Problem statement: Write a C++ program that reads a customer’s checking account information from a dat file and calculates his/her account balance. In particular, a menu-based application should be developed to perform the following functionalities iteratively until the user request to quit the program:
1.  Display the account summary: This option allows the user to enter a 3-digit customer ID (e.g., 007 for the customer name James Bond). The program should read-in an appropriate dat file (e.g., Cust_007.txt) corresponds to the customer ID and displays the account information including the total account balance on the console. [10 points]

2.  Deposit the amount into the account: This option allows the user to enter a 3-digit customer ID, adds the requested amount at the end of the file, and saves the file. The option should display the account information including the total account balance on the console.  [20 points]

3.  Withdraw the amount from the account: This option allows the user to enter a 3-digit customer ID, reads the customer’s dat file, verifies that the requested withdrawal is less than the account balance and then add the withdrawal amount at the end of the file. The option should display the account information including the total account balance on the console.

In case, if the requested withdrawal is greater than the account balance, the program should display an error message and terminate the transaction.  [25 points]

4.  Quit the program: This option terminates the program. [5 points]
Four test files are provided to test your program. The dat files are named based on the customer id. For instance, the first customer of the bank is the author of the book, Tony Gaddis and his customer ID is Cust_001. The dat file of his checking account is Cust_001.dat.
Input validations: The menu based option should not allow any options other than 1 to 4 [10 points]. The program should not allow the user to enter any negative numbers [10 points].
*/

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

int main()
{
    char user_choice, cust_id;
    ifstream inputFile;
    string filename, cust_data;

    cout << "Please enter the number that corresponds to the option you want to choose" << endl;
    cin >> user_choice;

    switch (user_choice)
    {
        case '1':
        {
            cout << "Please enter your 3-digit customer id" << endl;
            cin >> cust_id;

            switch (cust_id)
            {
            case'001':

                inputFile.open(Cust_001.dat);

                while (inputFile >> cust_data)
                {
                    cout << cust_data << endl;
                    inputFile.close();
                }
                    case'007'

                    case'020'

                    case'400'
            }

            break;
        }
        case '2': 
            cout << "Please enter your 3-digit customer id" << endl;
            break; 

        case '3':
            cout << "Please enter your 3-digit customer id" << endl; 
            break; 

        case '4':
            cout << "Please enter your 3-digit customer id" << endl;
            break; 
    }
}

Are the dat or txt files in the folder the executable is in?
I know in Visual Studio the folder can change based on your compiler settings so I can't tell you where these files go. You have to be somewhat familiar with your compiler, IDE, settings and your files.

commented: I copied the .dat files into the resource files of the program. +0

First

inputFile.open(Cust_001.dat);
    should be
inputFile.open("Cust_001.dat");

Second: The file Cust_001.dat must be in your 'current' directory i.e. Your command prompt may show it as C:\Users\user_name or some such location.
Third: You must use the CD (change directory) command to go to where your .dat file is located. Use the DIR command to verify the file is in the current directory.
Fourth: Then run the program using a relative path e.g. ..\..\build\myprogram.exe

Now for some further critique.
Your I/O handling is quite wrong.
Please go and read about how to:
check for a file's existence,
open a file and check it opened correctly,
using std::cerr for error message output,
use std::getline to read input,
confirm the input is not empty.

Also read this article about this type of code.
https://gehrcke.de/2011/06/reading-files-in-c-using-ifstream-dealing-correctly-with-badbit-failbit-eofbit-and-perror/

Your case statements are incorrect; '400' etc. are not valid character values. You are expecting a number.
If you are certain they are numbers then convert the strings to numbers.
Either directly or using a stringstream.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.