Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<conio.h>
- #include<string.h>
- struct Node {
- int Data;
- int stock;
- int price;
- char pname[30];
- struct Node *next;
- } *rear, *front = NULL;
- void tampil(){
- printf("BLUE MOTORCYCLE PARTS\n");
- printf(". . . . . . . . . . . .\n");
- printf("\n1. View Order List");
- printf("\n2. Add New Order");
- printf("\n3. Take Order");
- printf("\n4. Exit\n");
- }
- void delQueue()
- {
- int del;
- struct Node *temp, *var = rear;
- if (var == rear)
- {
- system("cls");
- tabel();
- printf("\n\n\nInput Number of Order [1...4] : ");
- scanf("%d",&del);
- rear = rear->next;
- free(var);
- }
- else{
- printf("\n--- There is no order in the list ---");
- }
- }
- void push(int value)
- {
- struct Node *temp;
- temp = (struct Node *) malloc(sizeof(struct Node));
- temp->Data = value;
- if (front == NULL)
- {
- front = temp;
- front->next = NULL;
- rear = front;
- }
- else
- {
- front->next = temp;
- front = temp;
- front->next = rear;
- }
- }
- void display()
- {
- struct Node *var = rear;
- if (var != NULL)
- {
- system("cls");
- tampil();
- tabel();
- while (var != front)
- {
- printf("\t%d", var->Data);
- var = var->next;
- }
- if (var == front)
- {
- printf("\t%d", var->Data);
- }
- printf("\n");
- }
- else{
- system("cls");
- printf("\nQueue is Empty\n");
- }
- }
- void tabel(){
- int quan,harga;
- char name[30];
- printf("\t\t--- Order List ---\n");
- printf("-+------+-------------------------------+----------+------------+-\n");
- printf(" | No. | Name Of Parts\t\t\t| Quantity | Unit Price |\n");
- printf("-+------+-------------------------------+----------+------------+-\n");
- printf(" | 1. | %c\t\t\t| 3 | 450000 |\n");
- printf(" | 2. | disk brake\t\t\t| 2 | 450000 |\n");
- printf(" | 3. | head lamp\t\t\t| 4 | 450000 |\n");
- printf(" | 4. | spion\t\t\t\t| 3 | 450000 |\n");
- printf("-+------+-------------------------------+----------+------------+-\n");
- }
- int main()
- {
- tampil();
- int i = 0;
- front = NULL;
- while (1)
- {
- printf(" \n>> Input Choice : ");
- scanf("%d", &i);
- switch (i)
- {
- case 1:
- {
- system("cls");
- display();
- break;
- }
- case 2:
- {
- int value;
- printf("\nInput the name of motorcycle's parts [3...30] : ");
- scanf("%d", &value);
- if( value != 3 || value <= 20){
- printf("Type [3...30] parts name : ");
- scanf("%d",&value);
- }
- printf("Input Quantity of Motorcycle's parts [1...20] : ");
- scanf("%d",&value);
- push(value);
- display();
- break;
- }
- case 3:
- {
- delQueue();
- display();
- break;
- }
- case 4:
- {
- system("cls");
- printf("Thank You");
- exit(0);
- }
- default:
- {
- system("cls");
- printf("\nWrong choice for operation\n");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement