Advertisement
Guest User

Untitled

a guest
Jan 6th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.31 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <windows.h>
  5.  
  6. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  7. int Login(char true_username[5]);
  8. int Password(char true1_username[5],char true_password[5],int a);
  9. void Add();
  10. void Modify();
  11. void View();
  12. void Search();
  13. void Sort();
  14. void Exit();
  15. char *Array[100][3];
  16. int u=0;
  17. int sum = 0;
  18. int main(int argc, char *argv[]) {
  19.     int x;
  20.     int a=0+rand()%1;
  21.     char Anwser[7];
  22.     char true_password[5];
  23.     char true_username[5] = "John";
  24.     int flag = 0;
  25.    
  26.    
  27.     do
  28.     {
  29.         x = Login(true_username);
  30.     }while(x != 0);
  31.     Password(true_username,true_password,a);
  32.     while(flag == 0){
  33.     printf("Please enter one of the following words(Add,Modify,View,Search,Sort or Exit):\n");
  34.     scanf("%s",&Anwser);
  35.     if(strcmp(Anwser,"Add") == 0){
  36.         Add();    
  37.     }
  38.     else if(strcmp(Anwser,"Modify") == 0){
  39.        Modify();
  40.     }
  41.     else if(strcmp(Anwser,"View") == 0){
  42.        View();
  43.     }
  44.     else if(strcmp(Anwser,"Search") == 0){
  45.          
  46.     }
  47.     else if(strcmp(Anwser,"Sort") == 0){
  48.        
  49.     }
  50.     else if(strcmp(Anwser,"Exit") == 0){
  51.        flag = 4;
  52.     }
  53.  
  54. }
  55.     return 0;
  56. }
  57. int Login(char true_username[5]){
  58.     char username[5];
  59.     printf("Please enter your username:\n");
  60.     scanf("%s",&username);
  61.     if(strcmp(true_username,username) == 0){
  62.         return 0;
  63.     }
  64.     else if(strcmp(true_username,username) != 0){
  65.         return 1;
  66.     }
  67. }
  68. int Password(char true1_username[5],char true_password[5],int a){
  69.     char password[5];
  70.     if(a == 0){
  71.     true1_username[0] = 'J';
  72.     true1_username[2] = 'H';}
  73.     else if(a == 1){
  74.     true1_username[1] = 'O';
  75.     true1_username[3] = 'N';}
  76.     true_password = true1_username;
  77.         do
  78.     {
  79.         printf("Please enter your password:\n");
  80.         scanf("%s",&password);
  81.     }while(strcmp(password,true_password) != 0);
  82.     return 0;
  83. }
  84. void Add(){
  85.     system("cls");
  86.     char i;
  87.     int sum = 0;
  88.     float wra;
  89.     int ther;
  90.    
  91.     printf("Enter meal\n");
  92.     scanf("%s",&Array[u][0]);
  93.     printf("Enter calories\n");
  94.     scanf("%d", &ther);
  95.  sum=sum+ther;
  96.  char c = (char) ther;
  97.  Array[u][1]='c';
  98.  printf("enter time\n");
  99. scanf("%f", &wra );
  100. i = (char) wra;
  101. Array[u][2]='i';
  102. if(wra>=05.00 && wra<12.00){
  103.    Array[u][3]= "prwino";
  104. }
  105. else if(wra>=12.00 && wra<20.00){
  106.     Array[u][3] = "mesimeriano";
  107. }
  108. else if(wra>=20.00 && wra<05.00){
  109.     Array[u][3] = "vradino";
  110. }
  111. u++;
  112.    
  113. }
  114.  
  115.  
  116. void Modify(){
  117.      system("cls");
  118.     int number;
  119.     int sum = 0;
  120.     int ther;
  121.     float wra;
  122.     int y;
  123.     char i;
  124.     for(y=0;y<3;y++){
  125.         printf("%s\n",Array[u][y]);
  126.     }
  127.     printf("Please enter a number:(1,2,3)\n");
  128.     scanf("%d",&number);
  129.    if(number == 1){
  130.     printf("Enter new meal:\n");
  131.      scanf("%s",&Array[u][0]);
  132.    }
  133.    else if(number == 2){
  134.     printf("Enter calories\n");
  135.     scanf("%d", &ther);
  136.     sum=sum+ther;
  137.  char c = (char) ther;
  138.    }
  139.    else if(number == 3){
  140.      printf("enter time\n");
  141. scanf("%f", &wra );
  142. i = (char) wra;    
  143.    }
  144. }
  145. void View(){
  146.     int i;
  147.     int y;
  148.     for(i=0;i<=u;i++){
  149.         for(y=0;y<=3;y++){
  150.                 printf("%s\n",Array[i][y]);
  151.         }
  152.     }
  153.     printf("%d %d\n",sum,u);
  154.  
  155. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement