Problem:
During a special sale at a store, a 10% discount is taken on purchases over $10.00. Write a program that asks for the amount of purchases, and then calculates the discounted price. The purchase amount will be input in cents (as an integer)
Enter amount of purchases:
2000
Discounted price:
1800
Update:use If and Switch method.
Copyright © 2024 QUIZLS.COM - All rights reserved.
Answers & Comments
Verified answer
Your source code here:
http://algoritmosurgentes.com/en/java.php?f=discou...
The math part is basically done like this:
if(price>10) price-=price/10;
//If price is more than 10, subtract 10% from the price.
public double getDiscountedPrice(double actualPrice) {
return (actualPrice - (actualPrice * 0.1));
}
Hope this helps!!!
Regards
SAM