Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.84 KB | None | 0 0
  1. #include <stdio.h> 
  2. #include <string.h>
  3. #include <stdlib.h>
  4.  
  5. int count=0;
  6. char find[100];
  7. int topup;
  8. struct data {
  9.  
  10.     char name[50];
  11.     int duration;
  12.     int amount;
  13.  
  14.  
  15. }nasabah [100];
  16.  
  17. void input() {
  18.     do{
  19.     printf ("Input Deposit Owner's Name [3..30]: ");
  20.     scanf ("%[^\n]",nasabah[count].name); fflush(stdin);
  21.     }while (strlen(nasabah[count].name) < 3 || strlen(nasabah[count].name) > 30);
  22.    
  23.     do{
  24.     printf ("Input Deposit's Duration [1/3/6/9/12: ");
  25.     scanf ("%d",&nasabah[count].duration); fflush (stdin);
  26.     }while (nasabah[count].duration != 1 && nasabah[count].duration != 3 && nasabah[count].duration != 6 && nasabah[count].duration != 9 && nasabah[count].duration != 12);
  27.    
  28.     do{
  29.     printf ("Input Deposit's Amount [50000 - 1000000]: ");
  30.     scanf ("%d",&nasabah[count].amount); fflush(stdin);
  31.     }while (nasabah[count].amount < 50000 || nasabah[count].amount >1000000);
  32.    
  33. }
  34.  
  35. void search() {
  36.    
  37.     do{
  38.     printf ("Input Deposit Owner's Name [3..30]: ");
  39.     scanf ("%[^\n]",find); fflush(stdin);
  40.     }while (strlen(find) < 3 || strlen(find) > 30);
  41.    
  42.     if ( strcmp(find,nasabah[count].name) == 0 ){
  43.        
  44.         do {
  45.             printf ("Input Deposit's Amount [Max %d]: ",nasabah[count].amount);
  46.             scanf ("%d",&topup); fflush(stdin);
  47.         }while(topup > nasabah[count].amount);
  48.    
  49.     }
  50.  
  51.     else
  52.         printf ("No Customer Found");
  53.         getchar();
  54.  
  55. }
  56.  
  57.  
  58. int main () {
  59.  
  60.         int menu;
  61.  
  62.     do{
  63.     system ("cls");
  64.     printf ("Gading Home Bank Investment\n");
  65.     printf ("1. View Data\n");
  66.     printf ("2. Add New Data\n");
  67.     printf ("3. Topup Amount\n");
  68.     printf ("4. Save & Exit\n\n");
  69.    
  70.     printf("Choose your menu [1..5] : ");
  71.     scanf ("%d",&menu); fflush(stdin);
  72.    
  73.            
  74.         switch (menu) {
  75.    
  76.                  
  77.        
  78.                 case 2 : input();
  79.                             count++;
  80.                             break;
  81.                
  82.  
  83.                 case 3 : search() ;
  84.                             break;
  85.    
  86.    
  87.    
  88.    
  89.    
  90.    
  91.         }
  92.    
  93.    
  94.    
  95.    
  96.    
  97.    
  98.    
  99.     }while (menu != 4);
  100.    
  101.  
  102.  
  103. return 0;
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement