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.............

Can you show what the program currently prints out and explain what is wrong with that output?

Also be sure to show what the input to the program was that generated that output.

To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'

Paste here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.