Quote:
Code:
else if (quantity <= 9)
totalCostOfPurchase = price * quantity;
else if (quantity >= 10)
totalCostOfPurchase = price * quantity - discount1;
else if (quantity <= 19)
|
A value of 0 is below 9, thus the calculation starts.
This can be handlet in the
if(quantity <= 0) put a return state here, and it will never go any further.
Also with the furhter calculations theres is a misshap, if a value of 15 or 20 for that matter is entered, only the
totalCostOfPurchase = price * quantity - discount1;
is beeing calculated, it never goes any further..
You need to make a more precise if() clause ie:
Code:
else if (quantity >= 0 && quantity <= 9)
totalCostOfPurchase = price * quantity;
else if (quantity >= 10 && quantity <= 19)
totalCostOfPurchase = price * quantity - discount1;
else if (quantity >= 20 && <= 49)
totalCostOfPurchase = price * quantity - discount2;
etc....