Advertisement
apl-mhd

m final assignment

Jun 23rd, 2019
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.95 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstring>
  4.  
  5. using  namespace std;
  6.  
  7.  
  8.  
  9.  
  10. int  cseId();
  11. int  complexNumber();
  12. int  stringMatch();
  13. int  intFloat();
  14. int password();
  15.  
  16.  
  17.  
  18. void menubar(){
  19.  
  20.     bool decision = true;
  21.  
  22.     while(decision){
  23.  
  24.         cout<<"1. cseId :\n";
  25.         cout<<"2. complexNumber :\n";
  26.         cout<<"3. stringMatch :\n";
  27.         cout<<"4. intFloat :\n";
  28.         cout<<"5. password :\n";
  29.  
  30.         string n;
  31.         cin>>n;
  32.  
  33.         if(n == "1" ){
  34.  
  35.             int flag = cseId();
  36.  
  37.             if (flag ==1)
  38.  
  39.                 cout<<"Accepted\n";
  40.             else
  41.                 cout<<"Not Accepted\n";
  42.  
  43.         }
  44.  
  45.         else if(n == "2"){
  46.  
  47.             int flag =  complexNumber();
  48.  
  49.             if (flag ==1)
  50.  
  51.                 cout<<"Accepted\n";
  52.             else
  53.                 cout<<"Not Accepted\n";
  54.  
  55.  
  56.         }
  57.         else if(n == "3"){
  58.  
  59.             int flag =  stringMatch();
  60.  
  61.             if (flag ==1)
  62.  
  63.                 cout<<"Accepted\n";
  64.             else
  65.                 cout<<"Not Accepted\n";
  66.  
  67.  
  68.         }
  69.         else if(n == "4"){
  70.             int flag = intFloat();
  71.  
  72.             if (flag ==1)
  73.  
  74.                 cout<<"Accepted\n";
  75.             else
  76.                 cout<<"Not Accepted\n";
  77.  
  78.  
  79.         }
  80.         else if(n == "5"){
  81.  
  82.             int flag = password();
  83.  
  84.  
  85.             if (flag ==1)
  86.  
  87.                 cout<<"Accepted\n";
  88.             else
  89.                 cout<<"Not Accepted\n";
  90.  
  91.         }
  92.         else{
  93.             cout<<"Invalid input, enter again \n";
  94.         }
  95.  
  96.     }
  97.  
  98. }
  99.  
  100.  
  101.  
  102. int main() {
  103.  
  104.     menubar();
  105.  
  106.  
  107.     return 0;
  108. }
  109.  
  110.  
  111.  
  112. int  cseId(){
  113.  
  114.  
  115.  
  116.     cout<<"Enter CSE id\n";
  117.  
  118.     string id;
  119.     cin>>id;
  120.  
  121.     if(id[0] == '0' && id[1]=='1' && id[2] == '1'){
  122.  
  123.         if(id[5] == '1' || id[5] == '2' || id[5] == '3'){
  124.  
  125.  
  126.             if(!(id[6] == '0' && id[7] == '0' && id[8] == '0')){
  127.  
  128.                 return  1;
  129.             }
  130.  
  131.         }
  132.     }
  133.  
  134.  
  135.         return 0;
  136.  
  137.  
  138. }
  139. int  complexNumber(){
  140.  
  141.     cout<<"Enter Complex Number\n";
  142.  
  143.     string id;
  144.     cin>>id;
  145.  
  146.     if ((id[0] <= '9' && id[0] >='0')  || (id[0] <= 'z' && id[0] >= 'a')) {
  147.  
  148.  
  149.         if (id[1] == '+'){
  150.  
  151.             if(id[2] ==  'i' || id[3] == 'i'){
  152.  
  153.  
  154.                 return  1;
  155.             }
  156.  
  157.         }
  158.     }
  159.  
  160.     return  0;
  161.  
  162.     }
  163.  
  164.  
  165.  
  166. int  stringMatch(){
  167.  
  168.     cout<<"Enter String\n";
  169.  
  170.  
  171.  
  172.     string id;
  173.     cin>>id;
  174.  
  175.     if(id.size() <4)
  176.         return 0;
  177.  
  178.     if(id[0] <=  '9' && id[0] >='0'){
  179.  
  180.  
  181.         if (id[1] <= 'Z' && id[1] >= 'A'){
  182.  
  183.             if (!(id[2] <= 'Z' && id[2] >= 'A') || !(id[2] <= 'z' && id[2] >= 'a') ){
  184.  
  185.                 if (((id[3] <= 'Z' && id[3] >= 'A')  || (id[3] <= 'z' && id[3] >= 'a')  || (id[3] <= '9' && id[3] >= '0'))){
  186.  
  187.  
  188.                     return  1;
  189.                 }
  190.  
  191.             }
  192.         }
  193.     }
  194.  
  195.  
  196.     return  0;
  197.  
  198.  
  199.  
  200. }
  201. int  intFloat(){
  202.  
  203.     cout<<"Enter Float number\n";
  204.  
  205.  
  206.     string id;
  207.     cin>>id;
  208.  
  209.     int  len = id.length();
  210.     for(int i=0; i<len; i++){
  211.  
  212.  
  213.         if((id[i] <= 'z' && id[i] >= 'a')){
  214.  
  215.             return 0;
  216.         }
  217.  
  218.     }
  219.  
  220.     if(id[len-1] == '.'){
  221.  
  222.  
  223.         return 0;
  224.     }
  225.  
  226.     return 1;
  227.  
  228.  
  229.  
  230.  
  231.  
  232. }
  233. int password(){
  234.  
  235.     cout<<"Enter Password\n";
  236.  
  237.  
  238.  
  239.  
  240.     string id;
  241.     cin>>id;
  242.  
  243.     int  len = id.length();
  244.  
  245.     int  upper =0;
  246.     int lower = 0;
  247.     int number = 0;
  248.  
  249.  
  250.  
  251.     if(len < 8){
  252.  
  253.         return 0;
  254.     }
  255.  
  256.  
  257.     for(int i=0; i<len; i++){
  258.  
  259.  
  260.         if((id[i] <= 'z' && id[i] >= 'a') ){
  261.  
  262.             lower++;
  263.         }
  264.  
  265.         if((id[i] <= 'Z' && id[i] >= 'A') ){
  266.  
  267.             upper++;
  268.         }
  269.  
  270.         if((id[i] <= '9' && id[i] >= '0') ){
  271.  
  272.             number++;
  273.         }
  274.  
  275.  
  276.     }
  277.  
  278.     if (lower == 0 || upper ==0 || number == 0){
  279.  
  280.         return 0;
  281.  
  282.     }
  283.  
  284.     if(!(id[len-1] !='@' || id[len-1] !='$' || id[len-1] !='#' || id[len-1] !='&')){
  285.  
  286.  
  287.         return  0;
  288.  
  289.     }
  290.  
  291.  
  292.     return  1;
  293.  
  294.  
  295. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement