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 11 of 11

Thread: need help on my project..

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default need help on my project..

    oh ok sir copeg.. im so sorry for my post..

    my problem is i want to display the getmidqtotal computation on my student so that i can display it in my viewmodel tab..


    THIS IS THE DISPLAY CODE TO DISPLAY THE GRADE
    static class ViewModel extends AbstractTableModel {
    private String[] columnNames = {"ID NUMBER","FAMILY NAME","FIRST NAME","MIDTERM","FINALS","FINAL GRADE"};
    private Object[][] data = storeObject();
    private Object[][] storeObject(){
    Vector vect = StdList.sort();
    Object[][] temp = new Object[vect.size()][6];
    for(int a=0;a<vect.size();a++){
    Student temp2 = (Student)vect.elementAt(a);
    Student temp3 = new Student();
    temp[a][0] = temp2.getIdNumber();
    temp[a][1] = temp2.getLastName();
    temp[a][2] = temp2.getFirstName();
    temp[a][3] = temp3.getmidqtotal();
    }
    return temp;
    }
    public Object[][] getData(){
    return data;
    }
    public int getColumnCount() {
    return columnNames.length;
    }
    public int getRowCount() {
    return data.length;
    }
    public String getColumnName(int col) {
    return columnNames[col];
    }
    public Object getValueAt(int row, int col) {
    return data[row][col];
    }
    public boolean isCellEditable(int row, int col) {
    return false;
    }
    }

    THIS IS MY STUDENT CLASS
    public Student(String first,String last,String mid,double midq1,double midq2,double midq3,double midl1,double midl2,double midw,double midh,
    double finq1,double finq2,double finq3,double finl1,double finl2,double finw,double finh){
    super(first,last,mid);
    midquiz1 = midq1;
    midquiz2 = midq2;
    midquiz3 = midq3;
    midlab1 = midl1;
    midlab2 = midl2;
    midwritten = midw;
    midhands = midh;
    finquiz1 = finq1;
    finquiz2 = finq2;
    finquiz3 = finq3;
    finlab1 = finl1;
    finlab2 = finl2;
    finwritten = finw;
    finhands = finh;
    addCount();
    }
     
     
    public void setmidqtotal(){
     midqscore = midquiz1 + midquiz2 + midquiz3;
     midqtotal = (midqscore/30*100)*0.20;
    }
     
    public double getmidqtotal(){
    return midqtotal;
    }
    Last edited by jikoy; March 19th, 2012 at 06:18 PM.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: need help on my project..

    Please wrap your code in the appropriate tags (read the forum rules to see how). And for the benefit of all I highly recommend posting an SSCCE

  3. #3
    Junior Member
    Join Date
    Mar 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: need help on my project..

    by the way thank you for the reply sir..
    Last edited by jikoy; March 19th, 2012 at 06:19 PM.

  4. #4
    Junior Member
    Join Date
    Mar 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: need help on my project..

    UP!!!!!!!!!!!!!

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: need help on my project..

    Do you have a specific problem or question about your code? Please post it.

    The formatting of your code (no indentations) makes it very hard to read and understand. Please edit the code and properly format it with indentations as per coding standards.

    What does the code display now? What do you want to change the display to look like?
    If you don't understand my answer, don't ignore it, ask a question.

  6. #6
    Junior Member
    Join Date
    Mar 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: need help on my project..

    i have now solved my problem about displaying the total value.. my problem now is it displays the same total value in 3 different columns..

    this is my code where i will display my stored data coming from my txtfile..
    i dont know whats wrong in my code its seems correct to me but it doesn't display what i want to display..
    temp[a][0] = temp2.getIdNumber();
    temp[a][1] = temp2.getLastName();
    temp[a][2] = temp2.getFirstName();
    /**this code is where i display the grade of the student. it shows the same total score in different columns.**/
    temp[a][3] = temp3.getmidtotal();
    temp[a][3] = temp3.getfintotal();
    temp[a][3] = temp3.getfinalgrade();


    also this is my code for calculating my total grade of my student
    just in case you need to understand the calculation of my inputed data from a textfield
    public void MidtermTotal(){
    	midtotal1 = midqtotal + midlabtotal + midhtotal + midwtotal;
    }
     
    public double getmidtotal(){
    	return midtotal1;
    }
     
    public void FinalTotal(){
    	fintotal1 = finqtotal + finlabtotal + finhtotal + finwtotal;
    }
     
    public double getfintotal(){
    return fintotal1;
    }
     
    public void FinalGrade(){
    	finalgrade = (midtotal1 + fintotal1)/2;
    }
     
    public double getfinalgrade(){
    	return finalgrade;
    }

    THANK YOU SOO MUCH FOR YOUR HELP SIR..
    Last edited by jikoy; March 21st, 2012 at 12:07 AM.

  7. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: need help on my project..

    it displays the same total value in 3 different columns..
    What data is in temp2 and what data is in temp3?
    Where does the total value that is being displayed come from?
    What is the problem with displaying the same value in 3 different columns?
    Do you think there should be different values displayed?
    If you don't understand my answer, don't ignore it, ask a question.

  8. #8
    Junior Member
    Join Date
    Mar 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: need help on my project..

    temp2 is the object of my student class it is use to get the data stored in my .txt

    temp3 is not in use.. you can ignore that.. sorry i accidentally put it..

    the problem is that in every column it should have a different value..
    column 4 is for my midterm total grade, column 5 is for my final total grade, and column 6 is for my final grade.. final grade value shoulde be midtotal1 + fintotal2

    yes.. there should be 3 different values as mentioned earlier..

  9. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: need help on my project..

    Where do each of the different values you want come from?
    Where do you set the values that should be in a column?
    Where do you put the values into columns 4,5 and 6?
    If you don't understand my answer, don't ignore it, ask a question.

  10. #10
    Junior Member
    Join Date
    Mar 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: need help on my project..

    this is the flow of my code

    this code will store the data i input in a textfield
     //component listeners
    	public void actionPerformed(ActionEvent e){
          //tab1
          if(e.getSource()==bt1ok){
            String fn = tf1fn.getText().trim().toUpperCase();
            String ln = tf1ln.getText().trim().toUpperCase();
            String mn = tf1mn.getText().trim().toUpperCase();
              Double midq1 = Double.parseDouble(tfmidq1.getText());
              Double midq2 = Double.parseDouble(tfmidq2.getText());
              Double midq3 = Double.parseDouble(tfmidq3.getText());
              Double midl1 = Double.parseDouble(tfmidl1.getText());
              Double midl2 = Double.parseDouble(tfmidl2.getText());
              Double midw = Double.parseDouble(tfmidw.getText());
              Double midh = Double.parseDouble(tfmidh.getText());
              Double finq1 = Double.parseDouble(tfmidq1.getText());
              Double finq2 = Double.parseDouble(tfmidq2.getText());
              Double finq3 = Double.parseDouble(tfmidq3.getText());
              Double finl1 = Double.parseDouble(tfmidl1.getText());
              Double finl2 = Double.parseDouble(tfmidl2.getText());
              Double finw = Double.parseDouble(tfmidw.getText());
              Double finh = Double.parseDouble(tfmidh.getText());
            Student temp;
            	temp = new Student(fn,ln,mn,midq1,midq2,midq3,midl1,midl2,midw,midh,
            			finq1,finq2,finq3,finl1,finl2,finw,finh);
            	//midterm
            	 temp.setmidqtotal();
            	 temp.setmidlabtotal();
            	 temp.setmidwtotal();
            	 temp.setmidhtotal();
            	 temp.MidtermTotal();
            	 //final
            	 temp.setfinqtotal();
            	 temp.setfinlabtotal();
            	 temp.setfinwtotal();
            	 temp.setfinhtotal();
            	 temp.FinalTotal();
            	 //final grade
            	 temp.FinalGrade();
            StdList.put(temp.getIdNumber(),temp);
            tf1id.setText(temp.getIdNumber());
            writeFiles();  readFiles();
            tb2view.setModel(new ViewModel());
            tb3passed.setModel(new PassedModel());
            tb4failed.setModel(new FailedModel());
           JOptionPane.showMessageDialog(null, "NEW RECORD SUCCESSFULY SAVED!");
          }

    and this code is my student class where i use a mutator and accessor to get the the and store it in my person class with a super method
    the add count method is just to increment my student id number..
      private static int  count;
      private String      IdNumber;
      private double midquiz1,midquiz2,midquiz3;
      private double midlab1,midlab2;
      private double midwritten,midhands;
      private double finquiz1,finquiz2,finquiz3;
      private double finlab1,finlab2;
      private double finwritten,finhands;
      private double midqtotal,midlabtotal,midwtotal, midhtotal;
      private double finqtotal,finlabtotal,finwtotal, finhtotal;
      private double midtotal1;
      private double midqscore,midlscore;
      private double finqscore,finlscore;
      private double fintotal1;
      private double finalgrade,lol;
     
     
     public Student(String first,String last,String mid,double midq1,double midq2,double midq3,double midl1,double midl2,double midw,double midh,
    		  double finq1,double finq2,double finq3,double finl1,double finl2,double finw,double finh){
        super(first,last,mid);
    	  midquiz1 = midq1;
    	  midquiz2 = midq2;
    	  midquiz3 = midq3;
    	  midlab1 = midl1;
    	  midlab2 = midl2;
    	  midwritten = midw;
    	  midhands = midh;
    	  finquiz1 = finq1;
    	  finquiz2 = finq2;
    	  finquiz3 = finq3;
    	  finlab1 = finl1;
    	  finlab2 = finl2;
    	  finwritten = finw;
    	  finhands = finh;
        addCount();
      }
     
     public Student(String first,String last,String mid,double mqtotal,double mlabtotal,double mwtotal,double mhtotal,
    		  double fqtotal,double flabtotal,double fwtotal,double fhtotal, double ftotal,double finalgrade1,double mtotal){
        super(first,last,mid);
        midqtotal = mqtotal;
        midlabtotal = mlabtotal;
        midwtotal = mwtotal;
        midhtotal = mhtotal;
        midtotal1 = mtotal;
        finqtotal = fqtotal;
        finlabtotal = flabtotal;
        finwtotal = fhtotal;
        finhtotal = fwtotal;
        fintotal1 = ftotal;
        finalgrade = finalgrade1;
        addCount();
      }
     
    public double getfinq1(){
    	return finquiz1;
    }
     
    public double getfinq2(){
    	return finquiz2;
    }
     
    public double getfinq3(){
    	return finquiz3;
    }
     
    public double getfinl1(){
    	return finlab1;
    }
     
    public double getfinl2(){
    	return finlab2;
    }
     
    public double getfinw(){
    	return finwritten;
    }
     
    public double getfinh(){
    	return finhands;
    }
     
    public double getmidq1(){
    	return midquiz1;
    }
     
    public double getmidq2(){
    	return midquiz2;
    }
     
    public double getmidq3(){
    	return midquiz3;
    }
     
    public double getmidl1(){
    	return midlab1;
    }
     
    public double getmidl2(){
    	return midlab2;
    }
     
    public double getmidw(){
    	return midwritten;
    }
     
    public double getmidh(){
    	return midhands;
    }
    //midterm
    public void setmidqtotal(){
    		midqscore = midquiz1 + midquiz2 + midquiz3;
    		midqtotal = (midqscore/30*100)*0.20;
    	}
     
    public double getmidqtotal(){
    	return midqtotal;
    }
     
    public void setmidlabtotal(){
    	midlscore = midlab1 + midlab2;
    	midlabtotal = (midlscore/40*100)*0.20;
    }
     
    public double getmidlabtotal(){
    	return midlabtotal;
    }
     
    public void setmidwtotal(){
    	midwtotal = midwritten * 0.30;
    }
     
    public double getmidwtotal(){
    	return midwtotal;
    }
    public void setmidhtotal(){
    	midhtotal = midhands * 0.30;
    }
     
    public double getmidhtotal(){
    	return midhtotal;
    }
     
    public void MidtermTotal(){
    	midtotal1 = midqtotal + midlabtotal + midhtotal + midwtotal;
    }
     
    public double getmidtotal(){
    	return midtotal1;
    }
    //finals
    public void setfinqtotal(){
    	finqscore = finquiz1 + finquiz2 + finquiz3;
    	finqtotal = (finqscore/30*100)*0.20;
    }
     
    public double getfinqtotal(){
    return finqtotal;
    }
     
    public void setfinlabtotal(){
    	finlscore = finlab1 + finlab2;
    	finlabtotal = (finlscore/40*100)*0.20;
    }
     
    public double getfinlabtotal(){
    return finlabtotal;
    }
     
    public void setfinwtotal(){
    	finwtotal = finwritten * 0.30;
    }
     
    public double getfinwtotal(){
    return finwtotal;
    }
    public void setfinhtotal(){
    	finhtotal = finhands * 0.30;
    }
     
    public double getfinhtotal(){
    return finhtotal;
    }
     
    public void FinalTotal(){
    	fintotal1 = finqtotal + finlabtotal + finhtotal + finwtotal;
    }
     
    public double getfintotal(){
    return fintotal1;
    }
     
    public void FinalGrade(){
    	finalgrade = (midtotal1 + fintotal1)/2;
    }
     
    public double getfinalgrade(){
    	return finalgrade;
    }

  11. #11
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: need help on my project..

    I was looking for answers to the questions I asked. Can you add comments to the code that:
    1)Show Where each of the different values you want comes from
    2)Show Where do you put the values into columns 4, 5 and 6?

    I don't see any comments in the code that answers these questions.

    For example:
    col5Val = <some data for column 5>;  // <<<<< HERE I STORE DATA in COLUMN 5
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Need some help on my HS Project
    By ntilli in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 12th, 2011, 09:22 PM
  2. Project - Please Help
    By toxikbuni in forum Java Theory & Questions
    Replies: 0
    Last Post: April 20th, 2010, 09:58 AM
  3. Can anyone help me on my project?
    By alesana514 in forum Paid Java Projects
    Replies: 1
    Last Post: December 16th, 2009, 09:24 AM
  4. Need Help With Project
    By jstew132 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 11th, 2009, 07:15 PM
  5. Need a project
    By helloworld922 in forum Project Collaboration
    Replies: 6
    Last Post: July 31st, 2009, 08:30 AM