Isamis Niversity: College of Computer Studies

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Misamis University

Ozamiz City 7200

COLLEGE OF COMPUTER STUDIES

ACTIVITY 07
IMPLEMENTING QUEUES

LEARNING OUTCOME:
1. Use the basic operations of a Queue data structure.

INSTRUCTIONS:

This is a collaborative activity. The partner(s) that you have in the Midterm Laboratory Exam will be
your partner in this activity. Only one program output will be uploaded per partner(s) but each must
submit an individual answer to follow-up questions.

Study the given program implementing the basic operations of a stack data structure in C program.
Retype the codes but using the Java program syntax and semantics. Run the program and inspect the
outputs.

The given program which will be used as basis for the modifications and enhancements of codes is
given below.

#include<stdio.h>
#include<conio.h>
#define MAX 5

void insert(int);
int del();
int queue[MAX], rear=0, front=0;
void display();
int main()
{
char ch , a='y';
int choice, token;
printf("1.Insert");
printf("\n2.Delete");
printf("\n3.show or display");
do
{
printf("\nEnter your choice for the operation: ");
scanf("%d",&choice);
switch(choice)
{
case 1: insert(token);
display();
break;

1
Misamis University
Ozamiz City 7200

COLLEGE OF COMPUTER STUDIES

ACTIVITY 07
IMPLEMENTING QUEUES

case 2:
token=del();
printf("\nThe token deleted is %d",token);
display();
break;

case 3:
display();
break;

default:
printf("Wrong choice");
break;
}
printf("\nDo you want to continue(y/n):");
ch=getch();
}
while(ch=='y'||ch=='Y');
getch();
return 0;
}

void display()
{
int i;
printf("\nThe queue elements are:");
for(i=rear;i<front;i++)
{
printf("%d ",queue[i]);
}
}

void insert(int token)


{
char a;
if(rear==MAX)
{
printf("\nQueue full");
return;
}

2
Misamis University
Ozamiz City 7200

COLLEGE OF COMPUTER STUDIES

ACTIVITY 07
IMPLEMENTING QUEUES

do
{
printf("\nEnter the token to be inserted:");
scanf("%d",&token);
queue[front]=token;
front=front+1;
printf("do you want to continue insertion Y/N");
a=getch();
}
while(a=='y');
}

int del()
{
int t;
if(front==rear)
{
printf("\nQueue empty");
return 0;
}
rear=rear+1;
t=queue[rear-1];
return t;
}

RUBRIC FOR GRADING

Criteria Very Satisfactory Satisfactory Fair Poor


(4) (3) (2) (1)
Correctness Program runs and Program works Program executes Program does not
completes all and completes but generates execute
 Converted C required tasks and most tasks incorrect results correctness
program to executes without appropriately and
Java errors fails to work on
special cases
 Running Java
program
User-friendly Includes all Some input or Lacks most or all No input/ output
input/output appropriate input output prompts/ input and output description
prompts and descriptions are descriptions
explains/ describes inappropriate or
all output values missing

3
Misamis University
Ozamiz City 7200

COLLEGE OF COMPUTER STUDIES

ACTIVITY 07
IMPLEMENTING QUEUES

Variables Variables are Some variable Poor use of Variables used are
named names are variable or incorrect
appropriately and inappropriate or inappropriate use
used efficiently variables are over- of variable names
used or under-used
Formatting/ Well-organized Disorganized tabs Poor use of tabs No use of tabs and
Readability and easy to follow and spaces or it and white space white spaces
through allows readability and is very
appropriate use of by someone who difficult to read
tabbing and white knows what is
spaces supposed to be
doing
Documentation Contains required Header and Comments are too Comments are
heading with comments are general missing
program inappropriate or
description and comments are
appropriate use of poorly described
comments

You might also like