/ Published in: Java
Question 1 for CS1030 Group 2 Assignment 7
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import java.util.*; public class taxCalculator { { // initialization and setup double foodBill = 150.00; // grocery bill total for food double foodTaxRate = 0.03; // food sales tax 3% double totalFoodTax = 0.00; // total food tax amount double nonFoodBill = 50.00; // grocery bill total for non-food double nonFoodTaxRate = 0.0675; // non food tax 6.75% double totalNonFoodTax = 0.00; // total non food tax amount double totalTaxes = 0.00;// total taxes for both food and nonfood bills double rounded; // total tax rounded to the nearest cent // do calculations totalFoodTax = foodBill * foodTaxRate; totalNonFoodTax = nonFoodBill * nonFoodTaxRate; totalTaxes = totalFoodTax + totalNonFoodTax; rounded = Round(totalTaxes, 2); // pass in totalTaxes to be rounded // and to which decimal place (2) // to the Round function //print results } // end main // round totalTaxes to the nearest cent public static double Round(double Rval, int Rpl) { Rval = Rval * p; return tmp/p; // return rounded value } // end Round } // end class