while should be true if 2
do while should be true if 3
and for should be true if 4
else all is falls\
import java.util.*;
import java.io.*;
public class Test {
public static void main(String args[]) throws IOException {
BufferedReader in = new BufferedReader (new InputStreamReader (System.in));
String input;
int x;
System.out.println("Number of Rows:\t");
x = Integer.parseInt (input = in.readLine());
for(int a=1;a<=x;a++)
{
System.out.print(a+"\tfor"); if((x%2)==1)System.out.print("\tTrue\n"); else System.out.print("\tFalse\n");
do{
a++;
System.out.print(a+"\tdo while"); if((x%2)==0)System.out.print("\tTrue\n"); else System.out.print("\tFalse\n");
while(a<=x)
{
a++;
System.out.print(a+"\twhile"); if((x%2)==1)System.out.print("\tTrue\n"); else System.out.print("\tFalse\n");
break;
}
break;}while(a<=x);
}
}
}

New Topic/Question
Reply



MultiQuote





|