Untitled

 avatar
unknown
plain_text
3 years ago
6.6 kB
5
Indexable
#include <iostream>
using namespace std;
#define MAX_Number 9999
#define MIN_Number 1000
#define div 100000000
#define SIZE 9  //logo size

void identification();
void Cheking_ID();
bool is_safe(char c);
int Menu();
void Checking_Credit();
void Cheking_Age();
bool check_email();
void Logo_company();
int random_generator(int,int);

int main()
{
	int counter = 0;
	int option = 0;
	char serviceOption = 0;
	identification();
	Cheking_ID();


	while (option != 4) {
		++counter;
		option = Menu();
		switch (option) {
		case 1:
			identification();
			Cheking_Age();
			check_email();
			Checking_Credit();
			cout << "Thank you for choosing our company and welcome! Our people will contact youshortly!" << endl;
			break;
		case 2:
			// print list to select what info required.
			serviceOption = second_Menu();
			while (serviceOption!='d') 
			{

				switch (serviceOption) 
				{
				case 'a':
					break;
					//how much i need to pay
					Checking_Credit();
					cout << "You need to play " << random_generator(20, 100) << endl;

				case 'b':
					Logo_company();
					cout << "SCE Internet Company is a growing internet service company located in Israel. More details can be found in our website." << endl;
					break;
					//know more about u
				case 'c':
					// read eamil
					cout << "Enter your email please: \n";
					while (!check_email()) {
						cout << "Please enter email in good format\n";
					}
					// some one will contac you.
					cout << "someone will contact you in 48 hours.\n";
					break;
					//speak with real human
				case 'd':
					break;
				default:
				}
			}
			break;
		case 3:
			// Contact customer support.
			// Check email
			cout << "You must speak with a service representative, please leave an email so that we can get back to you." << endl;;
			cout << "Enter your email:\n";
			if (check_email())
				cout << "We are sorry to hear you are unhappy. We will contact you in the next "<< random_generator(72,168) << "hours.\n";
			else
				cout << "Email not in correct format, please retry to enter email.\n";

			break;
		case 4:
			Logo_company();
			break;

		default:
			if (counter <= 3)
				cout << "Please retry\n";
			else
				cout << "Please come back only when you need something. Have a good day!\n";
		}
	}
	//  
	cout << "";
	Checking_Credit();
	Cheking_Age();



	return 0;
}

void identification()
{
	cout << "Enter name and press '.' at the end:" << endl;
	bool strValid = false;
	while (!strValid)
	{
		char inputChar = getc(stdin);
		if (inputChar < 'A' || inputChar>'Z')
		{
			continue;
		}
		bool scanningActive = true;
		while (scanningActive)
		{
			char inputChar = getc(stdin);
			if (inputChar == '.')
			{
				strValid = true;
				break;
			}

			if (inputChar < 'a' || inputChar>'z')
			{
				break;
			}

		}
	}
}

void Cheking_ID()
{
	long id;

	while (true)
	{
		cout << "Enter id: ";
		cin >> id;
		cin.clear();
		cin.ignore(1000, '\n');

		unsigned int check = id / div;

		if (id / div > 0 && id / div < 10)
			break;
		cout << "Please provide correct id:" << endl;
	}
}

int Menu()
{
	int select;
	cout << "Thank you for choosing SCE Internet Company! How can we help you?" << endl;
	cout << "" << endl;
	cout << "\n\t\tMENU :" << endl;
	cout << "Press 1\nI want to join your company as a new client." << endl;
	cout << "" << endl;
	cout << "Press 2\nI want to find out some details about my already existing account." << endl;
	cout << "" << endl;
	cout << "Press 3\nI want to leave your company." << endl;
	cout << "" << endl;
	cout << "Press 4\nI want to exit the chat." << endl;

	cin >> select;
	return select;
}

char second_Menu()
{
	char Select;
	cout << "What information are you after?" << endl;
	cout << "" << endl;
	cout << "\n\t\tMENU :" << endl;
	cout << "Press a\nI would like to know how much I need to pay this month." << endl;
	cout << "" << endl;
	cout << "Press b\nI would like to know more about you." << endl;
	cout << "" << endl;
	cout << "Press c\nI would like to speak with a real human." << endl;
	cout << "" << endl;
	cout << "Press d\nI want to return to the main menu." << endl;

	cin >> Select;
	return Select;
}

void Checking_Credit()
{
	int Card_NUM = 0;
	bool flag = true;

	cout << "Enter 4 last number of your card:" << endl;
	cin >> Card_NUM;
	while (Card_NUM > 9999 || Card_NUM < 1000)
	{
		flag = false;
		if (flag == false)
		{
			cout << "Error! Please try again:" << endl;
			cin >> Card_NUM;
		}
	}

	cout << "Correct" << endl;
}

void Cheking_Age()
{
	int age = 0;
	bool flag = 0;
	cout << "Enter your age:" << endl;
	cin >> age;

	while (age > 120 || age < 18)
	{
		flag == false;
		if (flag == false)
		{
			cout << "Your age is incorrect, Please try again:" << endl;
			cin >> age;
		}
	}
	cout << "Correct" << endl;

}

bool is_safe(char c) {
	if (c <= '9' && c >= '0')
		return true;
	if (c >= 'a' && c <= 'z')
		return true;
	if (c >= 'A' && c <= 'Z')
		return true;
	if (c == '_')
		return true;
	return false;
}

bool check_email()
{
	
	// @ flag
	bool domin_flag = false;
	// Bad Email
	bool bad_email = false;
	// Input char 
	char input=0,prev=0;


	while (input != ' ') {
		cin.get(input);
		if (!bad_email) {
			
			if (!is_safe(input)) {
				// Dot case
				if (input == '.' && prev == '.')
					bad_email = true;
				// @ case
				if (input == '@')
					if (domin_flag)
						bad_email = true;
					else
						domin_flag = true;
			}
			prev = input;
		}
	}
	cin.get(input);
	return !bad_email;

}

void Logo_company()
{
	int number = 0;
	cout << "Enter number between 3-9" << endl;
	cin >> number;
	for (int i = 0; i < SIZE; ++i)
	{
		for (int j = 0; j < SIZE; ++j)
		{

			if (number < 3 || number>9)
			{
				cout << "Error ,You entered an incorrect value: Try again." << endl;
				cin >> number;
				break;
			}

			if (i == 0 && j < number)
			{
				cout << "*";
			}

			if (i == 1 && j == 0)
			{
				cout << "*";
			}

			if (i == 2 && j < number)
			{
				cout << "*";
			}

			if (i == 3)
			{
				if (j == number - 1)
				{
					cout << "*";
				}
				else
					cout << " ";
			}

			if (i == 4 && j < number)
			{
				cout << "*";
			}
		}
		cout << endl;
	}
}

int random_generator(int min,int max) {
	
		srand(time(NULL));    //*Initialization of random*//
	int value = min + (rand() % (max - min));

	cout << value << endl;
}
Editor is loading...