x8o
01-24-2007, 04:33 AM
i am trying to understand how this while function works.
while (priceA >=0)
{
totalA += priceA;
priceA = Double.parseDouble(JOptionPane.showInputDialog
("Enter a purchase price in County A, -1 to quit"));
}
while (priceB >= 0)
{
totalB += priceB;
priceB = Double.parseDouble(JOptionPane.showInputDialog
("Enter a purchase price in County B, -1 to quit"));
}
i know the squiggly brackets make it so that while loop body is a block. however, what does the totalA/B += priceA/B; do? i know the JOptionPane is just another JOptionPane.
i'm trying to figure out how to get my while statement to work with my other code so that the loop continues until you enter -1 to quit. currently i have it working, however with this while statement, the answer is incorrect for the values for priceA/B do not get calculated into the total cost.
while (priceA >=0)
{
totalA += priceA;
priceA = Double.parseDouble(JOptionPane.showInputDialog
("Enter a purchase price in County A, -1 to quit"));
}
while (priceB >= 0)
{
totalB += priceB;
priceB = Double.parseDouble(JOptionPane.showInputDialog
("Enter a purchase price in County B, -1 to quit"));
}
i know the squiggly brackets make it so that while loop body is a block. however, what does the totalA/B += priceA/B; do? i know the JOptionPane is just another JOptionPane.
i'm trying to figure out how to get my while statement to work with my other code so that the loop continues until you enter -1 to quit. currently i have it working, however with this while statement, the answer is incorrect for the values for priceA/B do not get calculated into the total cost.