Keyboard.readInt()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kaleeswaran
    New Member
    • Mar 2007
    • 132

    Keyboard.readInt()

    hi!

    i tried to get the input through keyboard using keyboard.readIn t() method
    but after compilation error shows "variable keyboard undefined"
    i don't know how to solve the pbm..plzz tell me...and this is my pgm:
    import java.io.*;
    import keyboard.*;
    public class test
    {
    public static void main(String args[])
    {
    int number;
    int sum;
    int num;
    System.out.prin tln("Enter the number:");
    number=keyboard .readInt();
    sum=0;
    num=number;
    while(num>0)
    sum+=num--;
    System.out.prin tln("The sum of the first"+number+" integer is"+sum+".");
    }

    }
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by kaleeswaran
    hi!

    i tried to get the input through keyboard using keyboard.readIn t() method
    but after compilation error shows "variable keyboard undefined"
    i don't know how to solve the pbm..plzz tell me...and this is my pgm:
    import java.io.*;
    import keyboard.*;
    public class test
    {
    public static void main(String args[])
    {
    int number;
    int sum;
    int num;
    System.out.prin tln("Enter the number:");
    number=keyboard .readInt();
    sum=0;
    num=number;
    while(num>0)
    sum+=num--;
    System.out.prin tln("The sum of the first"+number+" integer is"+sum+".");
    }

    }
    Where did you get the keyboard package from? You should ask there how to use it first because it is not part of the standard Java API.

    Comment

    • kaleeswaran
      New Member
      • Mar 2007
      • 132

      #3
      fine how to use this method "Keyboard.readI nt()"

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by kaleeswaran
        fine how to use this method "Keyboard.readI nt()"
        Check your case. In the code you have a small k.

        Comment

        • kaleeswaran
          New Member
          • Mar 2007
          • 132

          #5
          yes i got it.
          thnk you...

          Comment

          • Ouzair
            New Member
            • Jul 2008
            • 1

            #6
            HI there...

            Actually, am getting the same problem here but it is not a prob with my case. Can i please get a solution?? Thanks a lot!

            Here is the prgm:

            class Simple2 {
            public static void main (String[] arg) {
            int[] counts = new int[10];
            System.out.prin t("Enter ten numbers: ");
            for (int i=0; i<10; i++)
            counts[i]=Keyboard.readI nt();
            for (int i=0; i<10; i++)
            System.out.prin t(counts[9-i] + " ");
            System.out.prin tln();
            }
            }

            Comment

            • r035198x
              MVP
              • Sep 2006
              • 13225

              #7
              Originally posted by Ouzair
              HI there...

              Actually, am getting the same problem here but it is not a prob with my case. Can i please get a solution?? Thanks a lot!

              Here is the prgm:

              class Simple2 {
              public static void main (String[] arg) {
              int[] counts = new int[10];
              System.out.prin t("Enter ten numbers: ");
              for (int i=0; i<10; i++)
              counts[i]=Keyboard.readI nt();
              for (int i=0; i<10; i++)
              System.out.prin t(counts[9-i] + " ");
              System.out.prin tln();
              }
              }
              Have you imported the Keyborad class? It's not part of the standard Java APIs.

              Comment

              Working...