janedelsantos 0 Newbie Poster

Help, how can I create a MULTILEVEL QUEUE ALGORITHM program?
I tried it but it crashes, does not build...
It would be okay if its in other language.

HERE IS THE SNIPPET CODE SAMPLE (c++):
//Enter Number of Process
cout<<"\nEnter the number of Processes:";
cin>>n;

//INPUT Arrival, Burst, and Priority
cout<<"\nEnter arrival time of process:\n";
for(i=0;i<n;i++)
{

do{

cout<<"P"<<i+1<<":";
cin>>a[i];

inputerror=cin.fail();
if(inputerror)
{
cin.clear();
cin.ignore(1000,'\n');
}
cin.sync();

}while((inputerror));
}

cout<<"\nEnter burst time of process:\n";
for(i=0;i<n;i++)
{

do{

cout<<"P"<<i+1<<":";
cin>>b[i];

inputerror=cin.fail();
if(inputerror)
{
cin.clear();
cin.ignore(1000,'\n');
}
cin.sync();

}while((inputerror));
}

cout<<"\nEnter priority of process (1-FP/2-BP):\n";
for(i=0;i<n;i++)
{

do{

cout<<"P"<<i+1<<":";
cin>>p[i];

inputerror=cin.fail();
if(inputerror)
{
cin.clear();
cin.ignore(1000,'\n');
}

cin.sync();

}while((inputerror));
}

//Enter Algorithm
cout<<endl;
cout<<"Algorithm: "<<endl
<<"[1]FCFS"<<endl
<<"[2]SJF-P"<<endl
<<"[3]SJF-NP"<<endl
<<"[4]P-P"<<endl
<<"[5]P-NP"<<endl
<<"[6]RR"<<endl
<<"-------------"<<endl;

do{

cout<<"Enter Alogrithm Number: ";
cin>>algo;

inputerror=cin.fail();
if(inputerror)
{
cin.clear();
cin.ignore(1000,'\n');
}
elseif(algo<1)
{
cin.clear();
cin.ignore(1000,'\n');
}
elseif(algo>6)
{
cin.clear();
cin.ignore(1000,'\n');
}

cin.sync();

}while((inputerror)||(algo<1)||(algo>6));

//Other Values
do{

cout<<"Foreground Process: ";
cin>>forground_process;

inputerror=cin.fail();
if(inputerror)
{
cin.clear();
cin.ignore(1000,'\n');
}

cin.sync();

}while((inputerror));

do{

cout<<"Quantum: ";
cin>>quantum;

inputerror=cin.fail();
if(inputerror)
{
cin.clear();
cin.ignore(1000,'\n');
}

cin.sync();

}while((inputerror));

do{

cout<<"Background Process: ";
cin>>background_process;

inputerror=cin.fail();
if(inputerror)
{
cin.clear();
cin.ignore(1000,'\n');
}

cin.sync();

}while((inputerror));

/*I DON'T KNOW HOW TO SHOW THIS, HELP...

Gantt Chart
<Gantt Chart here>

Table
<Populated Table>

TAT Total:?
TAT Average:?
WT Total:?
WT Average:?

*/

repeatConfirm();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.