I created a regform as a program but my problem is the total units is not displayed.....how can I make it compute the total units and display it........
here is the code that I made...
import java.io.*;
public class regform
{
public static void main(String args[])throws IOException
{
BufferedReader br= new BufferedReader (new InputStreamReader (System.in));
String name[]=new String[2];
String course[]=new String [2];
String days[]=new String [2];
String subject[]=new String [2];
String section[]=new String [2];
int time[]=new int [2];
int unit[]=new int [2];
int ID[]=new int [2];
int ctr=0;
int tu=0;
for(ctr=0;ctr<2;ctr++)
{
System.out.print("\n Enter name: ");
name[ctr]=br.readLine();
System.out.print("\n \t Enter ID: ");
ID[ctr]=Integer.parseInt(br.readLine());
System.out.print("\n \t Enter course: ");
course[ctr]=br.readLine();
System.out.print("\n \t Enter section: ");
section[ctr]=br.readLine();
for(ctr=0;ctr<2;ctr++)
{
System.out.print("\n Enter subject: ");
subject[ctr]=br.readLine();
System.out.print("\n Enter days: ");
days[ctr]=br.readLine();
System.out.print("\n Enter time: ");
time[ctr]=Integer.parseInt(br.readLine());
System.out.print("\n Enter unit: ");
unit[ctr]=Integer.parseInt(br.readLine());
}
tu=tu+unit[ctr];
}
for(ctr=0;ctr<2;ctr++)
{
System.out.print("\n");
System.out.print("\n");
System.out.print("\n NAME" + name[ctr]);
System.out.print("\n ID" + ID[ctr]);
System.out.print("\n COURSE" + course[ctr]);
System.out.print("\n SECTION" + section[ctr]);
for(ctr=0;ctr<2;ctr++)
{
System.out.print("\n");
System.out.print("\n");
System.out.print("\n SUBJECT" + subject[ctr]);
System.out.print("\n DAYS" + days[ctr]);
System.out.print("\n TIME" + time[ctr]);
System.out.print("\n UNIT" + unit[ctr]);
}
System.out.print("\n");
System.out.print("\n");
System.out.print("\n TOTAL UNIT" + tu);
}
}
}
thank you for the help.............