yet again i have become very confused on this program. This program is suppose to have the user be able to put numbers in from a keyboard or they have the choose of choosing a file with numbers in it. the program is suppose to acknowledge all the numbers in the file or what the user inputs.... in the CMD it is suppose to out put....
numbers count
n1 : 1 4
n2 : 6 5
n3 : 10 1
n4 : 2 3
ect...
it is suppose to keep count of the duplicates the user enters or is in the file entered.
i have the main layout done, but i am very confused by the equations needed and how the set up for the program should be. I have a good image of how the program is suppose to be set up I just need help getting the above out come.... it not much to go by but here is the code:
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
using namespace std;
int main()
{
int count(0), start(0), numberINPUT(0), choice(0);
int inputtotal[20];
string input[] = {"n1","n2","n3","n4","n5","n6","n7","n8","n9","n10","n11","n12","n13","n14","n15","n16","n17","n18","n19","n20"};
cout << "This program is suppose to read a list of integers into an array table."<<endl;
cout << "You will have a choice to input the integers your self or choose a file."<<endl;
cout << "If you are ready to begin enter 1, if not enter 2 and the program will exit."<<endl;
cin >> start;
if(start == 2)
{
exit(1);
}
else if (start == 1)
{
cout << "would you like to get the numbers from a file or would you like to enter them by hand"<<endl;
cout << "enter 3 if you would like to enter by hand or enter 4 if you would like the numbers out of a file"<<endl;
cin >> choice;
if(choice == 3)
{
for (count = 0; count << 20; count++)
{
cout << setw(9) << left << input[count] << " : ";
cin >> inputtotal[count];
}
for (count = 0; count < 20; count++)
input[count] += inputtotal[count];
input[20] = numberINPUT;
cout << "Output : " << endl;
for (count = 0; count < 20; count++)
{
cout << setw(9) << left << input[count]
<< setw(3) << right << inputtotal[count] << endl;
}
cout << numberINPUT << " is the total of all the numbers added up."<<endl;
}
else if(choice == 4)
{
int FILE(0);
ifstream in;
cout << "Please enter the name of the file you wish to use (Please add the format"<<endl;
cout << ".txt, .doc, .rft ect..)"<<endl;
cin >> FILE;
in.open("FILE");
if(in.fail())
{
cout<<"File will not open, file possible dont exist or is corrupted"<<endl;
exit(1);
}
if( in.is_open())
{
while(!in.eof())
{
cout<<FILE<<endl;
system("pause");
}
}
}
}
system("pause");
return 0;
}