SAADQUAMER

Project1.2

Aug 17th, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.30 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3.  
  4. void convertion() {}
  5. void edit() {}
  6.  
  7. void search() {}
  8. struct currency
  9. {
  10.     char S1[50];
  11.     float rate;
  12. };
  13. void details() {
  14.  
  15.     system("CLS");
  16.     FILE *view;
  17.     view=fopen("record.txt","r");
  18.     int test=0,choice;
  19.    struct currency rt;
  20.     printf("\n\tCountry\t\tRate\t\t\t\n");
  21.  
  22.     while(fscanf(view,"%s %f \n",&rt.S1,&rt.rate)!=EOF)
  23.     {
  24.         printf("\n%s %.2f%",rt.S1,rt.rate);
  25.         test++;
  26.     }
  27.     fclose(view);
  28.  
  29.     if (test==0)
  30.     {
  31.         printf("\nNO RECORDS!!\n");
  32.     }
  33.  
  34. view_list_invalid:
  35.     printf("\n\nEnter 1 to go to the main menu and 2 to exit:");
  36.     scanf("%d",&choice);
  37.  
  38.     if (choice==1)
  39.         Menu();
  40.     else if(choice==2)
  41.         admin();
  42.     else
  43.     {
  44.         printf("\nInvalid!\a");
  45.         goto view_list_invalid;
  46.     }
  47.  
  48.  
  49.  
  50. }
  51.  
  52. void add()
  53. {
  54.     system("CLS");
  55.     FILE *currency;
  56.  
  57.     int add,i,choice;
  58.  
  59.     currency = fopen("record.txt","a+");
  60.         printf("\n\t\t\t<<<<<<<<< ADD CURRENCY DATA >>>>>>>>>\n\n");
  61.  
  62.         printf("Enter How Many Country You Want To Add :");
  63.         scanf("%d",&add);
  64.         struct currency rt;
  65.         for(i=1;i<=add;i++){
  66.         printf("%d.Enter Your Country :",i);
  67.         scanf("%s",&rt.S1);
  68.         printf("%d Enter Your Country Rate:",i);
  69.         scanf("%f",&rt.rate);
  70.         printf("\t%d. %s, rate= %.2f\n\n",i,rt.S1,rt.rate);
  71.  
  72.         fprintf(currency,"%s,%.2f\n",rt.S1,rt.rate);}
  73.         printf("\nFile is written successfully");
  74.         fclose(currency);
  75.     printf("\n\t\t\t<<<<<< Country added successfully!>>>>>>>");
  76.     printf("\n\n\t\t Enter 1 to go to the Admin Panel and 2 to exit:");
  77.     scanf("%d",&choice);
  78.         switch(choice)
  79.     {
  80.     case 1:
  81.         admin();
  82.         break;
  83.     case 2:
  84.         Menu();
  85.         break;
  86. }
  87.  
  88. }
  89.  
  90.  
  91. void admin()
  92. {
  93.     system("CLS");
  94.     int choice;
  95.     printf("\n\t<<<<<<<<Currency Conversion Program>>>>>>>>>>>>\n");
  96.     printf("\n\t  <<<<<<<<Welcome To Admin Panel>>>>>>>>>>>>\n\n");
  97.     printf("\t  1) Add Country Information\n");
  98.     printf("\t  2) Edit Country Information\n");
  99.     printf("\t  3) Show Currency Details\n");
  100.     printf("\t  4) Search Country\n");
  101.     printf("\t  5) Exit\n");
  102.  
  103.  
  104.     printf("\n\t Enter Your Choice (1-6):");
  105.     scanf("%d",&choice);
  106.     switch(choice)
  107.     {
  108.     case 1:
  109.         add();
  110.         break;
  111.     case 2:
  112.         edit();
  113.         break;
  114.     case 3:
  115.         details();
  116.         break;
  117.     case 4:
  118.         search();
  119.         break;
  120.     case 5:
  121.         Menu();
  122.         break;
  123.     default:
  124.         printf("Invalid Input!!! Input Again...\n");
  125.  
  126.         admin();
  127.  
  128.     }
  129.  
  130.  
  131. }
  132. void user()
  133. {
  134.     system("CLS");
  135.     int choice;
  136.     printf("\n\t<<<<<<<<Currency Conversion Program>>>>>>>>>>>>\n");
  137.     printf("\n\t  <<<<<<<<Welcome To User Panel>>>>>>>>>>>>\n\n\n");
  138.     printf("\t  1) Search Country\n");
  139.     printf("\t  2) Currency Convertion\n");
  140.     printf("\t  3) Show Currency Details\n");
  141.     printf("\t  4) Exit\n");
  142.  
  143.  
  144.  
  145.     printf("\n\t Enter Your Choice (1-4):");
  146.     scanf("%d",&choice);
  147.     switch(choice)
  148.     {
  149.     case 1:
  150.         search();
  151.         break;
  152.     case 2:
  153.         convertion();
  154.         break;
  155.     case 3:
  156.         details();
  157.         break;
  158.     case 4:
  159.         Menu();
  160.         break;
  161.  
  162.     default:
  163.         printf("Invalid Input!!! Input Again...\n");
  164.  
  165.         user();
  166.  
  167.     }
  168.  
  169.  
  170. }
  171. int main()
  172. {
  173.     Menu();
  174.     return 0;
  175. }
  176. void Menu()
  177. {
  178.     system("CLS");
  179.     int choice;
  180.  
  181.     printf("\n\t<<<<<<<<Currency Conversion Program>>>>>>>>>>>>\n\n");
  182.  
  183.     printf("\t  <<<<<<<<Welcome To Main Menu>>>>>>>>>>>\n\n");
  184.     printf("\t  1) Admin Login\n");
  185.     printf("\t  2) User \n");
  186.     printf("\n\t Enter Your Choice (1 or 2):");
  187.     scanf("%d",&choice);
  188.     switch(choice)
  189.     {
  190.     case 1:
  191.         pass();
  192.         admin();
  193.         break;
  194.     case 2:
  195.         user();
  196.         break;
  197.     default:
  198.         printf("Invalid Input!!! Input Again...\n");
  199.         Menu();
  200.  
  201.     }
  202.     return 0;
  203. }
  204. int pass(void)
  205. {
  206.     int a=0,i=0;
  207.     char uname[10],c=' ';
  208.     char pword[10],code[10];
  209.     char user[10]="saad";
  210.     char pass[10]="207661";
  211.     do
  212.     {
  213.         system("cls");
  214.  
  215.         printf("\n  ************************** ADMIN LOGIN FORM  **************************  ");
  216.         printf("\n\n                       ENTER USERNAME:-");
  217.         scanf("%s", &uname);
  218.         printf("\n\n                       ENTER PASSWORD:-");
  219.         while(i<10)
  220.         {
  221.             pword[i]=getch();
  222.             c=pword[i];
  223.             if(c==13)
  224.                 break;
  225.             else
  226.                 printf("*");
  227.             i++;
  228.         }
  229.         pword[i]='\0';
  230.  
  231.         i=0;
  232.  
  233.         if(strcmp(uname,user)==0 && strcmp(pword,pass)==0)
  234.         {
  235.             printf("  \n\n\n     <<<<<<<<< WELCOME !!!! LOGIN IS SUCCESSFUL >>>>>>>>>\n\n\n");
  236.             system("PAUSE");
  237.             break;
  238.         }
  239.         else
  240.         {
  241.             printf("\n        <<<<<<<<<SORRY !!!!  LOGIN IS UNSUCESSFUL>>>>>>>>> \n\n");
  242.             a++;
  243.             if (a==3)
  244.             {
  245.                 printf("\nSorry you have entered the wrong username or password for three times!!!");
  246.  
  247.                 Menu();
  248.  
  249.             }
  250.  
  251.             system("PAUSE");
  252.  
  253.  
  254.  
  255.         }
  256.     }
  257.     while(a<=2);
  258.  
  259. }
Advertisement
Add Comment
Please, Sign In to add comment