Question
I have C++ code and it works. but, I want to change to Java code. can Chegg expert help me. #include using namespace std; int
I have C++ code and it works. but, I want to change to Java code. can Chegg expert help me.
#include
using namespace std;
int initialNumber[4];
int main()
{
void ShowResult();
//initialization
int NuberOfpage[20]={1,0,7,1,0,2,1,2,3,0,3,2,4,0,3,0,2,1,0,7},i,j,f12[3];
int num1=0,num2=0,countr=0,framsize=3;
int inital,current,current1;
for(i=0;i<3;i++)
{
initialNumber[i]=-1;
}
for(j=0;j<20;j++)
{
num1=0,num2=0;
for(i=0;i<3;i++)
{
if(initialNumber[i]==NuberOfpage[j])
{
num1=1;
num2=1;
break;
}
}
if(num1==0)
{
for(i=0;i<3;i++)
{
if(initialNumber[i]==-1)
{
initialNumber[i]=NuberOfpage[j];
num2=1;
break;
}
}
}
if(num2==0)
{
for(i=0;i<3;i++)
f12[i]=0;
for(current=j-1,current1=1;current1<=framsize-1;current1++,current--)
{
for(i=0;i<3;i++)
{
if(initialNumber[i]==NuberOfpage[current])
f12[i]=1;
}
}
for(i=0;i<3;i++)
{
if(f12[i]==0)
inital=i;
}
initialNumber[inital]=NuberOfpage[j];
countr++;
}
int i;
cout< for(i=0;i<3;i++) cout< } cout< return 0; } This is what it print out when I run c++ code 1 -1 -1 1 0 -1 1 0 7 1 0 7 1 0 7 1 0 2 1 0 2 1 0 2 1 3 2 0 3 2 0 3 2 0 3 2 4 3 2 4 0 2 4 0 3 4 0 3 2 0 3 2 0 1 2 0 1 7 0 1 The Number of page the faults: 9
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started