Coding kasir

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct node{
char nama[101];
 int variabel;
 struct node *prev, *next;
}*head, *tail;

void pushData(int variabel, char nama[]){
 struct node *NodeBaru = (struct node*)malloc(sizeof(struct node));
 struct node *zone = head;
 NodeBaru->variabel=variabel;
 strcpy(NodeBaru->nama, nama);
 NodeBaru -> prev=NULL;
 NodeBaru -> next=NULL;

 if(head==NULL){
  head=tail=NodeBaru;
 }
 else if(variabel<head->variabel){
  NodeBaru->next=head;
  head->prev=NodeBaru;
  head=NodeBaru;
 }
 else if(variabel>=tail->variabel){
  tail ->next = NodeBaru;
  NodeBaru->prev=tail;
  tail=NodeBaru;
 }
 else{
  while(variabel>=zone->next->variabel){
   zone = zone->next;
  }
  NodeBaru->prev=zone;
  NodeBaru->next=zone->next;
  zone->next->prev=NodeBaru;
  zone->next=NodeBaru;
 }
}
void DeleteData(char nama[]){
 struct node *NodeBaru = (struct node*)malloc(sizeof(struct node));
 struct node *zone;

 if(head==NULL){
  printf("item not found...\n\n");
 }else{
  if(strcmp(head->nama,nama)==0 && strcmp(tail->nama,nama)==0){
   printf("Success to delete item \"%s\" from download list.\n",head->nama);
   head=tail=NULL;
   free(zone);
  }else if(strcmp(head->nama,nama)==0){
   zone = head;
   printf("Success to delete item \"%s\" from download list.\n",zone->nama);
   head=head->next;
   head->prev=NULL;
   free(zone);
  }else if(strcmp(tail->nama,nama)==0){
   zone=tail;
   printf("Success to delete item \"%s\" from download list.\n",zone->nama);
   tail=tail->prev;
   tail->next=NULL;
   free(zone);
  }else{
   zone=head;
   do{
    zone = zone->next;
   }while(strcmp(nama,zone->nama)!=0 && zone!=tail);
   if(zone==tail){
    printf("item not found...\n");
   }else{
    printf("Success to delete item \"%s\" from download list.\n",zone->nama);
    zone->prev->next = zone->next;
    zone->next->prev = zone->prev;
    free(zone);
   }
   }
 }
}

void printData(){
 struct node *zone=head;
 int i=1;
 if(zone==NULL){
  printf("Item list is empty. . .\n");
 }else{
  while(zone!=NULL){
  printf("0%d. %s #%d\n", i++, zone->nama, zone->variabel);
  zone = zone->next;
  }
 }
}
int main(){
 int menu;
 char name[101];
 int panjang=0;
 int angka=0;
 do{
  printf("1. Add item\n");
  printf("2. View item list\n");
  printf("3. Remove item\n");
  printf("4. Exit\n");
  printf("Please choose: ");scanf("%d",&menu);getchar();
 
  switch(menu){
   case 1 :
   do{
    printf("Input item name [1..100]: ");
 scanf("%[^\n]",&name);
    panjang = strlen(name);
   }while(panjang<1 || panjang>100);
   do{
    printf("Input item price [1..10]: ");
 scanf("%d", &angka);
   }while(angka<1 || angka>10);
    pushData(angka,name);
    puts("");
    getchar();
    break;
   case 2 :
    printData();
    puts("");
    break;
   case 3 :
    printf("Input item name [2..100]: ");
 scanf("%[^\n]",&name);
    DeleteData(name);
    puts("");
    break;
   case 4 :
    printf("Thank You!\n\n");
    break;
  }
 }while(menu!=4);

 return 0;
}

//maaf pak saya kerjain sebisa saya :)

Comments