0

hye i want to know how to do the coding when the question give the no of items bought and the price. for example number of items bought 1-9 and the discount price for 0.01-10.00 is 0%, 10.01-100.00 is 2% and for 100.01 is 5%.

3rd Oct 2016, 12:17 AM
Ridwana Syasya
Ridwana Syasya - avatar
2 Respostas
0
use if-else control staments : int totalPrice = 100, discount; if(totalPrice <= 0) { discount = 0; } else if(totalPrice <= 100) { discount = 0.02; } else if(totalPrice == 100.01) { discount = 0.05; }
3rd Oct 2016, 3:15 AM
chetan acharya
chetan acharya - avatar
0
int numOfItems = 5; int price = 50; if(numOfItems > 0 && numOfItems < 10) { if(price > 10 && price <= 100) { price *= 0.98 } else if(price > 100) { price *= 0.95 } } System.out.println(price); //49
3rd Oct 2016, 3:52 AM
Mythos