這個項目對我來說是非常有必要的。所以請有人幫我解決它..自20天以來我一直試圖解決下面提到的問題....這是我的代碼有兩種方法,我是否將變量()中的變量調用到另一個方法中?我需要將變量()中的變量用於其他函數。如何將參數化變量從其他方法調用到另一個同一類中?
下面是變量法:
public void variables(String mm,String Maths,String computer,String english,String hindi,String arts,String physics,String chemistry,String biology,int mmi,int mmf,int Math,
int com,int hin,int eng,int art,int chem,int bio,int phy,int sum,float fin){
mm = Marks.getText();
mmi = Integer.parseInt(mm);
mmf = mmi*8;
Maths = jTextField2.getText().replaceAll("\\s","");
computer= jTextField6.getText().replaceAll("\\s","");
english = jTextField8.getText().replaceAll("\\s","");
hindi = jTextField7.getText().replaceAll("\\s","");
arts = jTextField9.getText().replaceAll("\\s","");
physics = jTextField3.getText().replaceAll("\\s","");
chemistry = jTextField4.getText().replaceAll("\\s","");
biology = jTextField5.getText().replaceAll("\\s","");
Math = Integer.parseInt(Maths);
com = Integer.parseInt(computer);
hin = Integer.parseInt(hindi);
eng = Integer.parseInt(english);
art = Integer.parseInt(arts);
chem = Integer.parseInt(chemistry);
phy = Integer.parseInt(physics);
bio = Integer.parseInt(biology);
sum = Math+com+hin+eng+art+chem+phy+bio;
fin = (sum*100)/mmf;
}
這是另一種方法:
//I want to call the variables of the Variables() method to this one..but how??
public void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
float flin = Third.variables(fin);
JOptionPane.showMessageDialog(null,"Your Percentage for this Cycle Test is: "+flin+"%");
this.dispose();
Fourth IV = new Fourth();
IV.setVisible(true);
}
很難說出你實際要求的是什麼。也許你想要一個數組?這是一個志願者幫助網站;如果你想要「緊急」的幫助,你可以按我平常的速度僱用我,最少2小時。 – chrylis
@chrylis我認爲你也應該告訴他你平常的速度,因爲他是堆棧溢出的新手。 –
@HimanshuMittal首先你需要改善你的問題代碼塊,以便它可以很容易閱讀 –