每次尝试运行该程序时,它都会终止,并且我不知道为什么?我试图让它在接收对话框输入时输出选民数据。每当我尝试运行该程序时,它都会终止。我玩过这些代码,但似乎无法弄清楚原因。任何帮助表示赞赏。
package voting;
import javax.swing.JOptionPane;
public class VotingData {
public static void main(String[] args) {
new VotingData();
}
VotingData(){
String[] choices = {"M","F"};
int gender = JOptionPane.showOptionDialog(null, "Select M for male and F for female", "Click a button", JOptionPane.DEFAULT_OPTION,
JOptionPane.INFORMATION_MESSAGE, null, choices, choices[0]);
String[] options = {"a","b"};
int age = JOptionPane.showOptionDialog(null, "Select a if you are older than 25 select b if younger", "Click a button", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[0]);
String[] choose = {"Yes","No"};
int ed = JOptionPane.showOptionDialog(null, "Select yes if you graduated college, select no if you did not", "Click a button", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, choose, choose[0]);
String[] decide = {"Trump","Biden"};
int president = JOptionPane.showOptionDialog(null, "Select your presidential canidate", "Click a button", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, decide, decide[0]);
double totalvoters, femalevoters, malevoters, femalebiden, malebiden, femaletrump, maletrump, femalecollegetrump, femalecollegebiden, u25trump, u25biden, totaltrump, totalbiden, totalcollege, totalnoncollege, u25total, over25total;
{
femalevoters=Double.parseDouble("F");
malevoters=Double.parseDouble("M");
totalvoters=femalevoters+malevoters;
totalbiden=Double.parseDouble("Biden");
totaltrump=Double.parseDouble("Trump");
totalcollege=Double.parseDouble("Yes");
totalnoncollege=Double.parseDouble("No");
u25total=Double.parseDouble("b");
over25total=Double.parseDouble("a");
femalebiden=((totalvoters-malevoters-totaltrump)/totalvoters*100);
femaletrump=((totalvoters-malevoters-totalbiden)/totalvoters*100);
malebiden=((totalvoters-femalevoters-totaltrump)/totalvoters*100);
maletrump=((totalvoters-femalevoters-totalbiden)/totalvoters*100);
femalecollegebiden=((totalvoters-malevoters-totalnoncollege- totaltrump)/totalvoters*100);
femalecollegetrump=((totalvoters-malevoters-totalnoncollege-totalbiden)/totalvoters*100);
u25biden=((totalvoters-over25total-totaltrump)/totalvoters*100);
u25trump=((totalvoters-over25total-totalbiden)/totalvoters*100);
int gender1=0;
while (gender1<20) {
System.out.println(age);
age++;
System.out.println("The total number of voters =" + totalvoters);
System.out.println("The total number of female voters =" + femalevoters);
System.out.println("The total number of male voters =" + malevoters);
System.out.println("The total percent of female Biden supporters =" + femalebiden);
System.out.println("The total percent of female Trump supporters =" + femaletrump);
System.out.println("The total percent of male Biden supporters =" + malebiden);
System.out.println("Thetotal percent of male Trump supporters =" + maletrump);
System.out.println("The total percent of female college educated
Bdien supporters =" + femalecollegebiden);
System.out.println("The total percent of female college edcucated
Trump suppoerters =" + femalecollegetrump);
System.out.println("The total percent of under 25 Biden supporters =" + u25biden);
System.out.println("The total percent of under 25 Trump supporters =" + u25trump);
System.out.println("The total amount of voters for Biden =" + totalbiden);
System.out.println("The total amount of voters for Trump =" + totaltrump);
System.exit(0);
}
}
}
}
答案 0 :(得分:0)
嗯...
你去那里
所有语法错误均已删除,我已向您显示了所需的指导。
lapply(listAB, function(x) x[names(x) != 'rubbish'])
注意:我没有涉及您的计算,也没有更改您提供的代码的输出。我只是按照问题中的解决了您的问题。
如有需要,请投票;)