how to take more than 1 console input
when i'm giving this code,it asks ntopics but then prints all the System.out.print() statements simultaneously and is asking for "no. of categories of this topic" i.e. ncatg directly without asking for maxcatg and topics.What is wrong with this code?
public static void main(String arg[])throws Exception
{
InputStreamReader isr=new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
System.out.print("enter no. of topics");
int ntopics=System.in.read();
String topics[]=new String[ntopics];
System.out.println("enter maximum no. of categories among all topics");
int maxcatg=System.in.read();
String catg[][]=new String[ntopics][maxcatg];
int ncatg[]=new int[ntopics];
System.out.println("enter topics");
for(int i=1;i<=ntopics;i++)
{
System.out.println("enter topic " +i);
topics = br.readLine();
System.out.println("enter no. of categories of this topic");
ncatg=System.in.read();
System.out.println("enter name of categories");
for(int j=1;j<=ncatg;j++)
{
catg[j] = br.readLine();
}
if(ncatg<maxcatg)
{
for(int k=ncatg+1;k<=maxcatg;k++)
{
catg[k]="";
}
}
}
}>

