// Write the method determineTax. The method is sent the amount of the // purcha
ID: 3741073 • Letter: #
Question
// Write the method determineTax. The method is sent the amount of the
// purchase and the tax rate. It returns a double value that is the
// amount of the tax.
// Note that the method determineTax does not print anything -- it
// just returns the value.
double m1 = determineTax(350.00, 0.06); // Michigan is 6%
double m2 = determineTax(79.99, 0.06);
double cal1 = determineTax(499.99, 0.0725); // California is 7.25%
System.out.printf("Here are the returned values: %.2f, %.2f, and %.2f ", m1, m2, cal1);
Explanation / Answer
DetermineTaxTest.java
public class DetermineTaxTest {
public static void main(String[] args) {
double m1 = determineTax(350.00, 0.06); // Michigan is 6%
double m2 = determineTax(79.99, 0.06);
double cal1 = determineTax(499.99, 0.0725); // California is 7.25%
System.out.printf("Here are the returned values: %.2f, %.2f, and %.2f ", m1, m2, cal1);
}
public static double determineTax(double amount, double percentage) {
return amount*percentage;
}
}
Output:
Here are the returned values: 21.00, 4.80, and 36.25
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.