Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java Program Assignment Design an OrderedList class. An ordered list is one that

ID: 3794836 • Letter: J

Question

Java Program Assignment

Design an OrderedList class. An ordered list is one that keeps its elements in order, but not necessarily in sorted order. A list of employees may be ordered by employee number even though such ordering may be contrary to their order if they were sorted by last name. The OrderedList class should contain an insert(Object o) method that inserts its object in the proper position in the list.

One major challenge in this project is designing your OrderedList class so that it will work for any kind of object. (Hint: Define an Orderable interface that defines an abstract precedes() method. Then define a subclass of Node that implements Orderable. This will let you compare any two Nodes to see which one comes before the other.)

Test your OrderedList class with both the HockeyPlayer and Inventory classes (from weeks 3 and 4, respectively). Create text files containing several examples of each object. You may use any text editor to create the files, but be very careful to follow the layout specified in the corresponding class.

For Inventory items, use ItemNumber to order the list elements. Since ItemNumber is presumably unique, this task will be straightforward. For HockeyPlayer, use the number of goals scored to order the elements of the list. Keep in mind that there may be multiple players with the same number of goals scored. Make sure your file entries are in random order before you begin.

Create a GUI interface that allows your users to select the file that is to be processed and displays the results of the ordering on the screen. Review the material on JFileChooser from week 4 to allow users to choose the file to process. Give them the ability to perform this function repeatedly.

To display your results, you have several GUI options. The most basic would be to string the data into a message box. You can also use a TextArea control or even a TableView.

Finally, create a distribution package using either Excelsior Jet or Launch4j that will install your application on a computer with minimal involvement from the end user.

Explanation / Answer

#include<iostream.h>
#include<conio.h>
struct process
{
int no;
int at,et,wt,tt;
int tet;
int t;
};

void main()
{
process p[99];
int i,j,k;
cout<<" Enter No of Processes:";
int np;
cin>>np;

for (i=0;i<np;i++)
{
cout<<" Enter Execution time of process"<<i+1<<":";
cin>>p[i].et;
p[i].tet=p[i].et;
p[i].at=p[i].t=p[i].tt=p[i].wt=0;
p[i].no=i+1;
}

cout<<" Enter Time Quantum:";
int q;
cin>>q;

cout<<" Entered Data";
cout<<" Process ET";
for(i=0;i<np;i++)
{
cout<<" "<<p[i].no<<" "<<p[i].et;
}

int totaltime=0;
for(i=0;i<np;i++)
{
totaltime+=p[i].et;
}

i=0;
k=0;

int rrg[99];
for(j=0;j<totaltime;j++)
{
if((k==0)&&(p[i].et!=0))
{
p[i].wt=j;
if((p[i].t!=0))
{
p[i].wt-=q*p[i].t;
}
}
if((p[i].et!=0)&&(k!=q))
{
rrg[j]=p[i].no;
p[i].et-=1;
k++;
}
else
{
if((k==q)&&(p[i].et!=0))
{
p[i].t+=1;
}
i=i+1;
if(i==np)
{
i=0;
}

k=0;
j=j-1;
}
}

/*
for(j=0;j<totaltime;j++)
{
cout<<" "<<rrg[j];
}
*/

int twt=0;
int ttt=0;
cout<<" Result Of Round Robin";
cout<<" PNo ET WT TT";
for(i=0;i<np;i++)
{
p[i].tt=p[i].wt+p[i].tet;
ttt+=p[i].tt;
twt+=p[i].wt;
cout<<" "<<p[i].no<<" "<<" "<<p[i].tet<<" "<<p[i].wt<<" "<<p[i].tt;
}

cout<<" Average Waiting Time:"<<(float)twt/np;
cout<<" Average Turn Around Time:"<<(float)ttt/np;

getch();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote