|  |  | 
          
            | [b]พอดีตรงช่อง count อ่ะครับ[/b] 
  
 ช่องความถี่อ่ะครับที่ผมติดปัญหาอยู่
 ที่นี้ปัญหาคือ
 มันจะสัมพันธ์กับช่องอัตรภาคชั้น
 ถ้าช่องอัตรภาคชั้นคือ
 12-17
 18-22
 23-28
 29-32
 เสร็จแล้วเลขที่เรา input เข้ามาคือ
 12, 12, 13, 14, 22, 32, 15, 27, 15
 ผลลัพธ์ช่อง ความถี่ก็จะคือ
 
 12-17 >> 6
 18-22 >> 1
 23-28 >> 1
 29-32 >> 1
 
 
 Code (Java)
 
 private void btnCalFreActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
        ListModel model = lstInput.getModel(); 
        String floor = txtInput1.getText();
        int FL = Integer.parseInt(floor);
        float num[] = new float[model.getSize()];
        String frq = txtInput2.getText();
        float FR = Float.parseFloat(frq);
        float min=0;
        float max=0;
        
        for(int i=0; i < model.getSize(); i++){
         Object o =  model.getElementAt(i);
         String s = o.toString();
         num[i]= Float.parseFloat(s);
         if(i==0){
             min = num[i];
             max = num[i];
         }
           else if(num[i]>max)
         {   	
            max = num[i];
         }
           else if(num[i]<min)
         {
            min = num[i];
         }
      
        }
        //ประกาศไว้คิดอันตรภาคชั้นตัวหลัง
        float total[] = new float[FL];
        //ประกาศไว้คิดจุดกึ่งกลาง
        float totalx = 0;
        float count = 0;
        for(int i = 0 ; i<FL ;i++)
        {   
            for(int j=0;j<model.getSize();j++){
                
            }
            float total1 = Float.sum(min,FR);
            float total2 = Float.sum(total[i],FR);
            DefaultTableModel dtm = (DefaultTableModel) tblShowFrequency.getModel();
            if(i == 0){
                dtm.addRow(new Object[]{i+1,min+"-"+total1,count,totalx = total1/2});
                total[i]=min;
            }
            else{
                dtm.addRow(new Object[]{i+1,total[i]+1+"-"+total2,count,totalx =total2/2});    
            }
            total[i+1] = Float.sum(total[i],FR);
        }
        
    }
 
 
 Tag : Java, JAVA
 
 
 |  
            |  |  
            | 
              
                |  |  |  |  
                |  | 
                    
                      | Date :
                          2018-10-30 12:55:25 | By :
                          ohmkyodai | View :
                          2666 | Reply :
                          1 |  |  |  
                |  |  |  |  |  
            |  |  
		            |  |