//Cecilia Rangel	 CSC5	 Chapter 8,				 P.487, #1
//
/**************************************************************
 *
 *  COMPUTE WHETHER CHARGE
 * ____________________________________________________________
 * This program will prompt the user for a seven digit charge
 * account number, if the number is in the array, it will be
 * deemed valid, otherwise it will be deemed invalid.
 * 
 *_____________________________________________________________
 * INPUT
 * accNum			: a seven digit number from the user.
 *
 * OUTPUT
 * message			: comformation on wether or not the number 
 *					 entered is valid or not.
 * ***************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;

int main() {
int validNum[18] = {5658845, 8080152, 1005231, 4520125, 4562555, 6545231,
						7895122, 5552012, 3852085, 8777541, 5050552, 7576651,
						8451277, 7825877, 7881200, 1302850, 1250255, 4581002};
	int accNum;   //INPUT - seven digit number entered by user
	int count;    //counter for element  
	int position; //the position of the element in the array
	bool found;   //flag to indicate whether value was found 
//
//Prompt user to enter charge account number
	cout << "Enter your charge account number.\n";
	cin >> accNum;
//
//Loop linear search to find entered acoount number	
	found = false;
	position = -1;
	for (count = 0; count < 18; count++)
	{
		if (accNum == validNum[count])
		{
			found = true;
			position = count;
			cout << "The number entered is valid.\n";
		}
 
	}
	if (position == -1)
	cout << "The number entered is invalid.\n";
	return 0;
}