I need help for Comp Sci

Riskhk

Senior member
Mar 4, 2000
469
0
0
Do you guys have any idea on how to display an array/ vector at increments of 2?

Im guessing I need to use a for loop
but how can i say print 2 arrays at a time on a screen?
for (int a = 0; a < catalog.size(); a++)
{
for (int a = 0;
Practitioner p = (Practitioner)catalog.elementAt(a);
p.generateDescription();
}
this is what i have right now..it prints all at once.
 

Geforcekj

Banned
Apr 19, 2001
1,260
0
0
did you say you need to know how the AA curve reacts with an expantionary fiscal policy? If not, then I can't help you...
 

Riskhk

Senior member
Mar 4, 2000
469
0
0
i got something down
does this make sense
char character = '*';
String oneLine = null;
while (1 == catalog.size() || 2 == catalog.size())
{
for (int a = 0; a < 3; a++)
{
Practitioner p = (Practitioner)catalog.elementAt(a);
p.generateDescription();
}
break;
}

while(a % 2 == 0 && catalog.size() >= 4)
{
Practitioner p = (Practitioner)catalog.elementAt(a);
p.generateDescription();
Practitioner p = (Practitioner)catalog.elementAt(a+1);
p.generateDescription();
}
do
{
System.out.println("Continue?");
oneLine = inn.readLine();
character = oneLine.charAt(0);
if(character == 'Y')
{
Practitioner p = (Practitioner)catalog.elementAt(a);
p.generateDescription();
Practitioner p = (Practitioner)catalog.elementAt(a+1);
p.generateDescription();
}
if(character == 'N')
{
break;
}
else
{
System.out.println("Not valid command, please reenter");
}
}
while(a != catalog.size());
 
Nov 7, 2000
16,403
3
81
Im not too clear on the exact specifications of your program, but from your first post, you could just modify the loop to increment by 2 instead of one. ie for(a = 0; a<catalog.size(); a+=2).
 

kev0ut

Banned
Oct 9, 2001
202
0
0
what do you want the output to be?

VectorA Element 1
VectorA Element 2
VectorA Element 3
VectorA Element 4

VectorB Element 1
VectorB Element 2
VectorB Element 3
VectorB Element 4


OR


VectorA Element 1
VectorB Element 1
VectorA Element 2
VectorB Element 2
VectorA Element 3
VectorB Element 3
VectorA Element 4
VectorB Element 4

I don't know what you mean by increments of 2.