Simple C++ program design, just need to modify the complete Cpp file, top-down design
//Name: yuelong su //CO SCI 243 //Lab 10 - pg441 #5 //date: 5/16/2019 //Description: program that reads in a list of integers into // an array with base type int. #include<iostream> #include<fstream> using namespace std; void showScreen(); int main() { int size(0), arr[50], i(0), choice; char filename[50]; showScreen(); cin >> choice; if(choice == 1)//user input option { cout << "\nHow many numbers? "; cin >> size; cout << "Enter " << size << " integers:\n"; for(i = 0; i < size; i++) //user input some numbers depending on the size user sat { cin >> arr[i]; } } if(choice != 1)//file option { cout << "\nEnter a file name with directory: "; cin >> filename; ifstream inFile(filename); while(inFile >> arr[i])//count how many numbers are in the file { size++; i++; } } for(i = 0; i < size; i++) { for(int j = 0; j <= i; j++) { if(arr[i] > arr[j]) { int temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } } } cout << "\nN Count\n"; for(i = 0; i < size; i++)//show the data to the screen in the required format { int count(1); while(arr[i] == arr[i + 1] && i < size)//count how many times the number appears in the file { count++; i++; } cout << arr[i] << " " << count << endl; } return 0; } void showScreen() { cout <<"This program that reads in a list;" <<"of integers into an array with base type int.\n"; cout << "Enter 1 for user input or other number for file input: "; }