i just wanted to get correct answer for this Student Quiz Caiculator Total Caicu
ID: 3716940 • Letter: I
Question
i just wanted to get correct answer for this
Explanation / Answer
public void actionPerformed(ActionEvent action)
{
switch(action.getActionCommand())
{
//calculateTotal is name of the instance for JButton-(Calculate Total)
case "calculateTotal": Calculate_Total();
break;
//Clear is name of instance for JButton-(Clear)
//quiz1,quiz2 and total are names of instances for JTextField class
case "clear":quiz1.setText("");
quiz2.setText("");
total.setText("");
break;
case "close": System.exit(0);
break;
}
}
public void Calculate_Total()
{
int value1=Integer.parseInt(quiz1.getText());
int value2=Integer.parseInt(quiz2.getText());
int sum=value1+value2;
total.setText(sum+"");
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.