Untitled
unknown
plain_text
3 years ago
5.6 kB
9
Indexable
#include <iostream>
using namespace std;
#define MAX_Number 9999
#define MIN_Number 1000
#define div 100000000
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 main()
{
int counter = 0;
int option = 0;
int serviceOption = 0;
identification();
Cheking_ID();
while (option != 4) {
++counter;
option = Menu();
switch (option) {
case 1:
identification();
Cheking_Age();
Checking_Credit();
break;
case 2:
// print list to select what info required.
serviceOption; // new minue function
switch (serviceOption) {
case a:
//how much i need to pay
Checking_Credit();
case b:
//know more about u
case c:
//speak with real human
case d:
//return to the main menu
}
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 (3) 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;
}
void second_Menu()
{
int 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 >> 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;
}
}
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;
}
}
Editor is loading...