20
Mar
2019

Sum of multiple checkbox values in a textbox

Views: 5
0 0
Read Time:1 Minute, 30 Second

Sum of multiple checkbox values in a textbox. Get complete coding of java program to show sum of multiple checkbox checked value and get their sum in a textbox. In this you will also know that how we can change the result of string data type into integer data type and get sum in textbox.

Here you can also find that how to sum multiple checkbox data and  change a string data type into an integer  data type and get their results into integer data type.

You would also like to visit:

pepsichk=new Checkbox(“pepsi=50”);
pepsichk.setBounds(20,80,100,25);

saladchk=new Checkbox(“salad=100”);
saladchk.setBounds(20,110,100,25);

totallb=new Label(“total”);
totallb.setBounds(10,160,100,25);

totaltxt=new TextField(30);
totaltxt.setBounds(120,160,100,25);

calbt=new Button(“calculate”);
calbt.setBounds(30,200,100,25);
calbt.addActionListener(this);

add(pizzachk);
add(pepsichk);
add(saladchk);
add(totallb);
add(totaltxt);
add(calbt);
setVisible(true);
}

public void actionPerformed(ActionEvent ae)
{
int total=0;
String str=””;
if(ae.getSource()==calbt)
{
if(pizzachk.getState())
total=total+500;

if(saladchk.getState())
total=total+100;
totaltxt.setText(str.valueOf(total));
}
}
}
class fast
{
public static void main(String str[])
{
pizzaframe f=new pizzaframe();
}
}

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *