0

can anyone help me with this question? (java)

"the customer has to enter the numbers of item being purchased and also the price per item. if the customer buys more than 10 items, 5% discount will be given to the total price"

28th Oct 2019, 3:44 PM
Boon
Boon - avatar
3 Respostas
+ 1
You would need 2 variables: float totalPrice int countProducts You could create a loop, that separately asks user for item number and their price. If the given input for item number is empty, the loop will break. Otherwise it will ask for the price, add the price to totalPrice, increase countProducts by 1 and continue to the next iteration. When the loop breaks, there could be an if statement, that checks whether countProducts is atleast 10. If it is atleast 10, the totalPrice would be multiplied by 0.95 . And in the end the totalPrice would be printed.
28th Oct 2019, 4:12 PM
Seb TheS
Seb TheS - avatar
0
Yes
28th Oct 2019, 3:54 PM
Seb TheS
Seb TheS - avatar
0
how?
28th Oct 2019, 3:55 PM
Boon
Boon - avatar