can you help me correct my java code......I do not know what is wrong with it...

import java.io.*;
public class info
{
    public static void main (String args[])throws IOException
    {
        BufferedReader br= new BufferedReader (new InputStreamReader(System.in));
        String name,course; char section; int id,ctr=0,answer=0;

        do

            for(ctr=0;ctr>=3;ctr++)
            {
            System.out.print("\n Enter Name: ");
            name=br.readLine();
            System.out.print("\n Enter Course: ");
            course=br.readLine();
            System.out.print("\n Enter ID: ");
            id=Integer.parseInt(br.readLine());
            System.out.print("\n Enter Section: ");
            section=br.readLine().charAt(0);

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


            System.out.print("\n gusto mo pa ba??? press 1 oo 2 hindi.");
            answer=Integer.parseInt(br.readLine());



    }while(answer==1);
}


}

thank you so much.....

Please post error

can you help me correct my java code......I do not know what is wrong with it...

public static void main (String args[])throws IOException

don't do this. where exactly do you think you're throwing this exception to? look at it as being a war: the main method is your "last line of defense". if you catch this exception and handle it within your main method, you still can show a nice error message instead of completely crashing your application, but if you do it like this, once an IOException occurs, you won't be able to save your application from going 'bye-bye'.

for(ctr=0;ctr>=3;ctr++)

now HERE is your problem. unless you think 0 will ever be equal to or bigger than 3, you should understand that this for loop will never run.

just replace this line with

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

this will make your code run the way you want it too if (and only if) your user never enters an invalid value for the input when you ask for '1' or '2'. There are better ways to do this than using a BufferedReader. using the scanner class, for example, but that's not really related to the problem you've had so far.

Keep the code most simple as u can. In ur code u made several logical error. Try this code below.

import java.io.*;
import java.util.Scanner;

public class info {    
    public static void main(String[] args) {
        //BufferedReader br= new BufferedReader (new InputStreamReader(System.in));
        Scanner br=new Scanner(System.in);
        String name,course,ide,section;
        int id,ctr,answer=0;
       while (answer != 1)
       {
          // for(ctr=0;ctr<=3;ctr++){
            System.out.print(" Enter Name: ");
            name=br.next();
            System.out.print(" Enter Course: ");
            course=br.next();
            System.out.print(" Enter ID: ");
            ide=br.next();
            // id=Integer.parseInt(ide);
            System.out.print(" Enter Section: ");
            section=br.next();
            System.out.println(name);
            System.out.println(course);
            System.out.println(ide);
            System.out.println(section);
           System.out.println("\n gusto mo pa ba??? press 1 oo 2 hindi.");
           answer=br.nextInt();
           //}        
       } } }

Goodbye.

Keep the code most simple as u can. In ur code u made several logical error. Try this code below.

import java.io.*;
import java.util.Scanner;

public class info {    
    public static void main(String[] args) {
        //BufferedReader br= new BufferedReader (new InputStreamReader(System.in));
        Scanner br=new Scanner(System.in);
        String name,course,ide,section;
        int id,ctr,answer=0;
       while (answer != 1)
       {
          // for(ctr=0;ctr<=3;ctr++){
            System.out.print(" Enter Name: ");
            name=br.next();
            System.out.print(" Enter Course: ");
            course=br.next();
            System.out.print(" Enter ID: ");
            ide=br.next();
            // id=Integer.parseInt(ide);
            System.out.print(" Enter Section: ");
            section=br.next();
            System.out.println(name);
            System.out.println(course);
            System.out.println(ide);
            System.out.println(section);
           System.out.println("\n gusto mo pa ba??? press 1 oo 2 hindi.");
           answer=br.nextInt();
           //}        
       } } }

Goodbye.

don't just say: "you made several logical mistakes" point them out and explain to him/her what it is you changed and why that does the work.

also, don't just hand out code, give him pointers and give him a chance to discover things for himself.

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.