Question: My program is suppossed to find all the unique combinations of three numbers in a sequence of numbers that add to a requested sum. The
My program is suppossed to find all the unique combinations of three numbers in a sequence of numbers that add to a requested sum. The program is suppossed to read in the starting list of numbers from a file, allow the user to update and change the starting sequence of numbers, using data validation for user entries, and calculate and display statistics and write out the final results to a file. My started program and question number 7 is as follows and i cant seem to make it run or figure out how to input number 7 into my file.
7. File input. The program should prompt for the file to be imported, requesting the name and then appending .txt. The file should be opened and imported per Chapter 8 protocol. On some lines, illegal entries will be included such as numbers mixed with letters and letters by themselves, see Figure 3. The program should use Chapter 9 string and character functions to only accept valid integers. The file length will vary. Also, various example files will be included such as file1. Txt shown in Figure 1. 33 aa4 3a1 31 14! Hello 14 Figure 3. Example file. From this file only 33, 31 and 14 should be extracted.
#include "Header.h"
#include
#include
#include
using namespace std;
void fileinput(vector
void fileoutput(vector
void startingsequence(vector
void isvalid
int main()
{
int op; //menu option
vector
vector
cout << "Welcome to find the three ";
//
//create a menu
//
cout << "Enter the following operation" << endl;
cout << "1: file input " << endl;
cout << "2: Starting sequence " << endl;
cout << "3: search sum " << endl;
cout << "4: Count statistics" << endl;
cout << "5: Bar graph" << endl;
cout << "6: Column graph" << endl;
cout << "7: File output " << endl;
cout<< "8: Exit ";
do
{
cout << "Please enter a menu item ";
cin >> op;
cin.ignore();
switch (op)
{
case 1:
cout << "you entered file input "
fileinput(nums);
for (int i = 0; i < nums.size(); i++)
cout << nums.at(i) << endl;
break;
case 2:
startingsequence(nums);
case 7:
cout << "you entered file output ";
count.push_back(3);
count.push_back(10);
fileoutput(count);
break;
case 8:
cout << "You entered quit ";
break;
default:
cout << "incorrect entry";
}
}
while (op != 8);
cout << "Thanks for playing Find the 3 ";
system("pause");
}//end main
void fileinput(vector
void fileoutput(vector
bool isvalidint(string str)
void startingsequence(vector
{
int i;
//display the vector
for (i = 0; i < n.size(); i++)
cout << i << " " << n.at(i) << endl;
i = 5;
n.erase(n.begin() + 1);
for (i = 0; i < n.size(); i++)
cout << i << " " << n.at(i) << endl;
return;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
