Advertisement
Guest User

Untitled

a guest
Feb 26th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.78 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <math.h>
  5.  
  6. //char password[15] = "L3tM3in";
  7. //char username[15] = "Admin19";
  8.  
  9. void login();
  10. void menu(int *option);
  11.  
  12. int main()
  13. {
  14. login();
  15.  
  16.  
  17.  
  18. int option = 0;
  19. while(option != 4){
  20. printf(" Drug Admin. System\n");
  21. printf("Menu:\n 1. Check Quantity\n 2.Refill\n 3.Dispense\n 4.Quit\n\nSelect Option:\n");
  22. scanf("%d", &option);
  23. menu(&option);
  24.  
  25. }
  26.  
  27.  
  28. return 0;
  29.  
  30.  
  31.  
  32. }
  33. void menu(int *option){
  34.  
  35. int a = 40; //Amoxil
  36. int s = 40; //Synthroid
  37. int z = 30;//Zestril
  38. int v = 10;//Vicodin
  39.  
  40. switch(*option){
  41. case(1):
  42. system("@cls||clear");
  43. printf(" Current Quantities\n");
  44. printf("Amoxil %d\nSynthroid %d\nZestril %d\nVicodin %d\n\n", a, s, z, v);
  45. getchar();
  46. char pick;
  47. while(pick != 'b'){
  48. printf("Return to menu press b: \n");
  49. pick = getchar();
  50. getchar();
  51. if(pick == 'b'){
  52. system("@cls||clear");
  53. break;
  54. }
  55.  
  56. }
  57.  
  58.  
  59. }
  60.  
  61.  
  62. }
  63.  
  64.  
  65.  
  66. /*system("@cls||clear");
  67. printf(" Current Quantities\n");
  68. printf("Amoxid %d\nSynthroid %d\nZestril %d\nVicodin %d\n", a, s, z, v);
  69. char returnMenu[2] = {'n', '\0'};
  70. char returnMenu1;
  71.  
  72. int returnCorrect = 1;
  73.  
  74. int i;
  75.  
  76.  
  77.  
  78. do{
  79. returnCorrect = 1;
  80. i = 0;
  81. printf("Return to menu press b: \n");
  82. returnMenu1 = getchar();
  83. while(returnMenu1 != '\n'){
  84. if(returnMenu[i] != returnMenu1){
  85. returnCorrect = 0;
  86. printf("no");
  87.  
  88. }
  89.  
  90. i++;
  91. returnMenu1 = getchar();
  92.  
  93. }
  94.  
  95. system("@cls||clear");
  96. }while(returnCorrect != 1);
  97. } */
  98.  
  99.  
  100.  
  101.  
  102. /*do{
  103. printf("Return to menu press b: \n");
  104. pick = getchar();
  105. getchar();
  106.  
  107. }while(pick != 'b');
  108.  
  109. while(pick[0] == 'b'){
  110. break;
  111.  
  112. }
  113.  
  114.  
  115. }while ()
  116.  
  117.  
  118.  
  119. }
  120. }
  121. //printf("Return to menu press b: \n");
  122. //pick = getchar();
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131. /*printf("%d", *option);
  132. if(*option == 1){
  133. system("@cls||clear");
  134. printf("Amoxil %d\nSynthroid %d\nZestril %d\nVicodin %d\n\n", a, s, z, v);
  135. getchar();
  136. char pick;
  137. do{
  138. printf("Return to menu press b: \n");
  139. pick = getchar();
  140. getchar();
  141.  
  142.  
  143.  
  144. }while(pick != 'b');
  145. while(pick == 'b'){
  146. break;
  147. }
  148.  
  149.  
  150.  
  151. }
  152. else if(*option == 2){
  153.  
  154.  
  155. }else if(*option == 3){
  156.  
  157.  
  158. }
  159. else{
  160.  
  161. printf("Quit Program\n");
  162.  
  163.  
  164. } */
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172. void login()
  173. {
  174. char username[15] = "test";
  175. char password[15] = "test";
  176. char username1;
  177. char password1;
  178.  
  179. int nameCorrect = 1;
  180. int passCorrect = 1;
  181. int i = 0;
  182. int j = 0;
  183.  
  184. int size = 4;
  185. do{
  186.  
  187. nameCorrect = 1;
  188. passCorrect = 1;
  189. i = 0;
  190. printf("Enter username:");
  191. username1 = getchar();
  192. while(username1 != '\n'){
  193. if(username[i] != username1){
  194. nameCorrect = 0;
  195. printf("no");
  196.  
  197. }
  198. i++;
  199. username1 = getchar();
  200.  
  201. }
  202. j = 0;
  203. printf("Enter Password:");
  204. password1 = getchar();
  205. while(password1 !='\n'){
  206. if(password[j] != password1){
  207. passCorrect = 0;
  208.  
  209. }
  210. j++;
  211. password1 = getchar();
  212.  
  213. }
  214.  
  215. system("@cls||clear");
  216.  
  217.  
  218. }while(((nameCorrect != 1) || (passCorrect != 1)) || i != size || j != size);
  219.  
  220.  
  221. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement