Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <math.h>
- //char password[15] = "L3tM3in";
- //char username[15] = "Admin19";
- int a = 40; //Amoxil
- int s = 40; //Synthroid
- int z = 30;//Zestril
- int v = 10;//Vicodin
- void login();
- void menu(int *option);
- void refill(int *a, int *quantity);
- void dispense(int *drug, int *amount);
- //void dispenseS(int *s, int *quantity);
- //void dispenseZ(int *z, int *quantity);
- //void dispenseV(int *v, int *quantity);
- int main()
- {
- login();
- int option = 0;
- while(option != 4){
- printf(" Drug Admin. System\n");
- printf("Menu:\n 1.Check Quantity\n 2.Refill\n 3.Dispense\n 4.Quit\n\nSelect Option:\n");
- scanf("%d", &option);
- menu(&option);
- }
- return 0;
- }
- void menu(int *option){
- /*int a = 40; //Amoxil
- int s = 40; //Synthroid
- int z = 30;//Zestril
- int v = 10;//Vicodin*/
- switch(*option){
- case 1:{
- system("@cls||clear");
- printf(" Current Quantities\n");
- printf("Amoxil %d\nSynthroid %d\nZestril %d\nVicodin %d\n\n", a, s, z, v);
- getchar();
- char pick;
- char next;
- int count = 0;
- while(pick != 'b' || count != 2){
- count = 0;
- next = 'c';
- printf("Return to menu press b: \n");
- while(next != '\n'){
- next = getchar();
- if(count == 0){
- pick = next;
- }
- count++;
- }
- }
- system("@cls||clear");
- break;
- }
- case 2:{
- int choice = 0;
- int quantity = 0;
- system("@cls||clear");
- printf("Select drug by #\n1.Amoxil 2. Synthroid 3. Zestril 4. Vicodin\n");
- scanf("%d", &choice);
- printf("Enter refill quantity:");
- scanf("%d", &quantity);
- if(choice ==1)
- refill(&a, &quantity);
- else if(choice ==2)
- refill(&s, &quantity);
- else if(choice == 3)
- refill(&z, &quantity);
- else if (choice == 4)
- refill(&v, &quantity);
- else{
- }
- break;
- }
- case 3:{
- int choice = 0;
- int quantity = 0;
- system("@cls||clear");
- printf("Select drug by #\n1.Amoxil 2. Synthroid 3. Zestril 4. Vicodin\n");
- scanf("%d", &choice);
- printf("Enter quantity to dispense:");
- scanf("%d", &quantity);
- if(choice ==1)
- dispense(&a, &quantity);
- else if(choice ==2)
- dispense(&s, &quantity);
- else if(choice == 3)
- dispense(&z, &quantity);
- else if(choice == 4)
- dispense(&v, &quantity);
- else{
- }
- break;
- }
- case 4:
- system("@cls||clear");
- printf("Quit program.");
- }
- system("@cls||clear");
- }
- void refill(int *a, int *quantity){
- // printf("drug = %d\n",*a);
- // printf("quantity = %d",*quantity);
- *a+= *quantity;
- // printf("New drug amount is %d", *a);
- }
- void dispense(int *drug, int *amount){
- if(*amount <= *drug){
- *drug-= *amount;
- }
- else if(*amount > *drug){
- printf("Not enough quantity to dispense.\n");
- getchar();
- char pick;
- char next;
- int count = 0;
- while((pick != 'n' && pick != 'y') || count != 2){
- count = 0;
- next = 'c';
- printf("Press y to go back to dispense again. Press n to return to main menu: \n");
- while(next != '\n'){
- next = getchar();
- if(count == 0){
- pick = next;
- //printf("%c", pick);
- }
- count++;
- }
- }
- if(pick == 'n'){
- //printf("heyo");
- return;
- }
- else if(pick == 'y'){
- int temp = 3;
- menu(&temp);
- }
- }
- }
- void login()
- {
- char username[15] = "Admin19";
- char password[15] = "L3tM3in";
- char username1;
- char password1;
- int nameCorrect = 1;
- int passCorrect = 1;
- int i = 0;
- int j = 0;
- int size = 7;
- do{
- nameCorrect = 1;
- passCorrect = 1;
- i = 0;
- printf("Enter username:");
- username1 = getchar();
- while(username1 != '\n'){
- if(username[i] != username1){
- nameCorrect = 0;
- printf("no");
- }
- i++;
- username1 = getchar();
- }
- j = 0;
- printf("Enter Password:");
- password1 = getchar();
- while(password1 !='\n'){
- if(password[j] != password1){
- passCorrect = 0;
- }
- j++;
- password1 = getchar();
- }
- system("@cls||clear");
- }while(((nameCorrect != 1) || (passCorrect != 1)) || i != size || j != size);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement