Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: can't get my entered values

  1. #1
    Junior Member
    Join Date
    Aug 2014
    Posts
    9
    My Mood
    Confused
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default can't get my entered values

    i want to enter student records and i made functions and arrays for that...the problem is i can't get my entered values and back to me and the output is "null" please check screen shot also.
    package javaapplication10;
     
    import javax.swing.JOptionPane;
    public class JavaApplication10 {
     
        int count=0;
        public int x=10;
        public int rollno[];
     
        public String[] name;        
           public String[] sclass;
           public int[] marks;
           public void JavaApplication10()//constructor
           {
             rollno=new int[10];
             name=new String[10];
             sclass=new String[10];
             marks=new int[10];
     
     
           }
     
           public void addrec(int a,String b,String c,int d)
           {
     
           count++;
     
           }
           public void deletrec()
           {
     
           }
           public void viewrec()
           {
     
               for (int i=0;i<=9;i++)
           System.out.println(rollno[i]+"\t"+name[i]+"\t"+sclass[i]+"\t"+marks[i]);
     
           }
     
        public static void main(String[] args) {
            // TODO code application logic here
          JavaApplication10 objjj=new  JavaApplication10();
          objjj.JavaApplication10();
          String r=JOptionPane.showInputDialog("enter the roll number");
          int R=Integer.parseInt(r);
         String n=JOptionPane.showInputDialog("enter the name of student");
         String c=JOptionPane.showInputDialog("enter the class of student");
         String m=JOptionPane.showInputDialog("enter the marks of student");
         int M=Integer.parseInt(m);
         objjj.addrec(R,n,c,M);
         objjj.viewrec();
     
     
        }
     
    }
    Attached Images Attached Images


  2. #2
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: can't get my entered values

    What should your addrec() method be doing? It doesn't seem correct.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  3. #3
    Junior Member
    Join Date
    Aug 2014
    Posts
    9
    My Mood
    Confused
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: can't get my entered values

    Quote Originally Posted by aussiemcgr View Post
    What should your addrec() method be doing? It doesn't seem correct.
    by addrec method i want to enter record by passing values from function

  4. #4
    Member
    Join Date
    Feb 2011
    Posts
    33
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default Re: can't get my entered values

    There is nothing in the addrec method to store the parameter values in the array. Here's an example of how you would do that...

    public void addrec(int a,String b,String c,int d)
    {
       rollno[count] = a;
       count++;
    }

    You would do the same for each entry.


    All intelligent thoughts have already been thought;
    what is necessary is only to try to think them again.



  5. The Following User Says Thank You to WhiteSoup12 For This Useful Post:

    want2code (August 9th, 2014)

  6. #5
    Junior Member
    Join Date
    Aug 2014
    Posts
    9
    My Mood
    Confused
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: can't get my entered values

    Quote Originally Posted by WhiteSoup12 View Post
    There is nothing in the addrec method to store the parameter values in the array. Here's an example of how you would do that...

    public void addrec(int a,String b,String c,int d)
    {
       rollno[count] = a;
       count++;
    }

    You would do the same for each entry.
    I'm loving this forum this really helped me thanks whitesoup

  7. #6
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: can't get my entered values

    You mean you love spoonfeeding. The question posed by aussiemcgr was meant to get you thinking about why your code didn't do what you wanted.
    Improving the world one idiot at a time!

Similar Threads

  1. Replies: 2
    Last Post: October 26th, 2013, 09:56 AM
  2. Replies: 2
    Last Post: October 26th, 2013, 09:56 AM
  3. Updating MySQL with user entered values
    By Talksin in forum JDBC & Databases
    Replies: 0
    Last Post: May 16th, 2013, 10:13 AM
  4. Save data entered upon reopening
    By SHStudent21 in forum Java Theory & Questions
    Replies: 1
    Last Post: February 12th, 2011, 10:24 PM
  5. Replies: 1
    Last Post: December 4th, 2010, 05:26 PM