//Diego Martinez					CSC5				    Chapter 8, P.487, #1
/*******************************************************************************
*  DISPLAY CHARGE ACCOUNT VALIDATION 
* ______________________________________________________________________________
* This program allows the user to enter a charge account number and checks 
* whether the number exists in a predefined list of valid account numbers using 
* a linear search. The program then displays a message indicating whether the 
* entered account number is valid or invalid.
* 
* Computation is based on the Formula:
*	accounts[i] = accountNumber
*______________________________________________________________________________
* INPUT
*	accountNumber : Charge account number entered by the user
* 
* OUTPUT
*	Message stating whether the account number is VALID or INVALID
*******************************************************************************/
#include <iostream>
using namespace std;

int main()
{
	// Array of valid charge accounts
	int accounts[18] = {
		5658845, 4520125, 7895122, 8777541, 8451277, 1302850,
		8080152, 4562555, 5552012, 5050552, 7825877, 1250255,
		1005231, 6545231, 3852085, 7576651, 7881200, 4581002
	};
	
	int accountNumber;
	bool found = false;
	
	//Ask user for account number
	cout << "Enter a charge account number: ";
	cin >> accountNumber;
	
	// Linear search 
	for (int i = 0; i < 18; i++)
	{
		if (accounts[i] == accountNumber)
		{
			found = true;
	}
}

// Display result
if (found)
{ 
	cout << "The account number is VALID." << endl;
}
else {
	cout << "The account number is INVALID." << endl;
}
return 0;
}