hi there I am trying to get this calculation to work correctly but it seems that I am unable to get it working….
what it should do is add the following (flower + colour = amount) x size = total amount for example when (rose 1.2 + white 1.3) is selected it should x by size lets say medium 7.5 selected and give a total which is 10.00 it should be 18.75 which is incorrect at the moment when I try It the calculations are incorrect it coming back with a incorrect value .. I’ve looked at the code again and can’t see where i’m going wrong here’s the code for the calculations…
`subtotal = flowerChoice == 1 ? rosePrice : // Use ternary operator for flower price
flowerChoice == 2 ? lilyPrice :
flowerChoice == 3 ? carnationsPrice :
flowerChoice == 4 ? daffodilPrice :
flowerChoice == 5 ? gerberaPrice :
flowerChoice == 6 ? chrysanthemumPrice :
assortedPrice;
subtotal += colourChoice == 1 ? whitePrice : // Use ternary operator for color price
colourChoice == 2 ? redPrice :
colourChoice == 3 ? pinkPrice :
colourChoice == 4 ? yellowPrice :
colourChoice == 5 ? bluePrice :
mixedPrice;
subtotal += sizeChoice == 1 ? smallPrice : // Use ternary operator for size price
sizeChoice == 2 ? mediumPrice : largePrice;
System.out.printf("Subtotal: £%.2fn", subtotal);
also what I would like it to do is this print out the chosen flower + chosen colour + chosen size = to total amount:`
any help is really appreciated
😉
tim
what it should do is add the following (flower + colour = amount) x size = total amount for example when (rose 1.2 + white 1.3) is selected it should x by size lets say medium 7.5 selected and give a total which is 10.00 it should be 18.75
Timski is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.