Write a C++ program that processes charge account numbers. Input will come from
ID: 3622451 • Letter: W
Question
Write a C++ program that processes charge account numbers. Input will come from a file and some of the output will go to a file. Both file names should be entered from the keyboard at run time in the main program.
1. Refer to Programming Problems #1 and # 4 on page 503. Use the list of numbers from #1 for the input file for the test case. Insert a -1 at the end of this list as the sentinel. These numbers should be read by your program and stored in a single-dimensional array of type long. Assume there will be no more than 20 numbers, but your code should check that the user doesn't attempt to enter more. If an attempt is made to enter 21, print an error message on the screen and process only the first 20.
2. Print an appropriate program purpose and labels on both the screen output and the file output. Print the unsorted numbers on the output file, four numbers per line.
3. Use the selection sort algorithm given in your text to sort your array. Print the the sorted array on the output file, four numbers per line.
4. The user should enter a number from the keyboard. Your program should print a message on the screen saying whether or not the number is in the list. The binary search should be used to determine if the number is valid.
5. Your design should include at least four functions in addition to the main function. The selection sort code and the code to perform a binary search should be two of the functions.
6. Your name as programmer should appear on the output file and on the screen.
This is the Input File need to be in txt format
Screen Output:
Explanation / Answer
Hope this helps. Let me know if you have any questions. Please rate. :) Tested and it works fine on my computer. Let me know if you have any issues or questions. Be sure to change the "YOUR NAME HERE" part. #include #include #include using namespace std; const int maxAccounts = 20; void selectionSort(int[], int); void swap(int[], int, int); int readFile(ifstream&, int[]); void printAccounts(ofstream&, int[], int); bool binarySearch(int[], int, int); int main() { ifstream inFile; ofstream outFile; string inputFileName; string outputFileName; int accounts[maxAccounts]; int accountsRead; int search; cout inputFileName; inFile.open(inputFileName.c_str()); if (!inFile.is_open()) { cerrRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.