We are suppose to create a registration form but it is not running! can you please help me and teach me what is wrong and what i am suppose to put! thank you! here is my code....

import java.io.*;

public class regform
{
	public static void main(String args[])throws IOException
	{
		BufferedReader br= new BufferedReader (new InputStreamReader (System.in));
		String name,course,days,subject,section,time;
		int unit,ID;
		int ctr=0;

		for(ctr=0;ctr<3;ctr++)
		{

			System.out.print("\n Enter name: ");
			name=br.readLine();
			System.out.print("\n Enter ID: ");
			ID=Integer.parseInt(br.readLine());
			System.out.print("\n Enter course: ");
			course=br.readLine();
			System.out.print("\n Enter section: ");
			section=br.readLine();

			for(ctr=0;ctr<5;ctr++)
			{

				System.out.print("\n Enter subject: ");
				subject=br.readLine();
				System.out.print("\n Enter days: ");
				days=br.readLine();
				System.out.print("\n Enter time: ");
				time=br.readLine();
				System.out.print("\n Enter unit: ");
				unit=Integer.parseInt(br.readLine());

			}
		}


		for(ctr=0;ctr<3;ctr++)
		{

			System.out.print("\n " + name);
			System.out.print("\n " + ID);
			System.out.print("\n " + course);
			System.out.print("\n " + section);


			for(ctr=0;ctr<5;ctr++)
			{

				System.out.print("\n " + subject);
				System.out.print("\n " + days);
				System.out.print("\n " + time);
				System.out.print("\n " + unit);
			}

		}


	}
}

Recommended Answers

All 4 Replies

Stop abusing colour formatting every time you post something it will not get your question solved faster. Instead post what error messages you get when you tried to compile or run this thing.

import java.io.*;
     
    public class regform
    {
    public static void main(String args[])throws IOException
    {
    BufferedReader br= new BufferedReader (new InputStreamReader (System.in));
    String name = null,course = null,days = null,subject = null,section = null,time = null;
    int unit = 0,ID = 0;
    int ctr=0;
     
    for(ctr=0;ctr<3;ctr++)
    {
     
    System.out.print("\n Enter name: ");
    name=br.readLine();
    System.out.print("\n Enter ID: ");
    ID=Integer.parseInt(br.readLine());
    System.out.print("\n Enter course: ");
    course=br.readLine();
    System.out.print("\n Enter section: ");
    section=br.readLine();
     
    for(ctr=0;ctr<5;ctr++)
    {
     
    System.out.print("\n Enter subject: ");
    subject=br.readLine();
    System.out.print("\n Enter days: ");
    days=br.readLine();
    System.out.print("\n Enter time: ");
    time=br.readLine();
    System.out.print("\n Enter unit: ");
    unit=Integer.parseInt(br.readLine());
     
    }
    }
     
     
    for(ctr=0;ctr<3;ctr++)
    {
     
    System.out.print("\n " + name);
    System.out.print("\n " + ID);
    System.out.print("\n " + course);
    System.out.print("\n " + section);
     
     
    for(ctr=0;ctr<5;ctr++)
    {
     
    System.out.print("\n " + subject);
    System.out.print("\n " + days);
    System.out.print("\n " + time);
    System.out.print("\n " + unit);
    }
     
    }
     
     
    }

You Forget to intialize String var to null.

And why are u calling loop 3 and 5 times....

create a registration form but it is not running

Please explain what you want your code to do in more detail.
Show what it does now and add comments describing how the output is incorrect and what you want the output to look like.

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.