-
April 3rd, 2013, 04:16 PM
#1
Addition help
Hi all,
I was wondering if you could help me with the following problem. I need help adding the prices together, I am confused on what the code is. The following code is correct, just I don't know how to add the prices together. e.g.
2 waters and 1 food equals £3.15
Code:
public void actionPerformed(ActionEvent e) {
DecimalFormat pound= new DecimalFormat("#.##");
select= (String) JOptionPane.showInputDialog
(project.this,"Select",
Select,JOptionPane.INFORMATION_MESSAGE, null, products,
"food");
if (select.equals("food"))
price = 0.65;
else if (select.equals("water"))
listprices = 1.25;
else
price = 0.0;
listmodel.addElement(select+ " £" +pound.format(price));
}
Thanks in advance,
hypon
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|