Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

calculate tip and sales tax function

    public static void solve(double meal_cost, int tip_percent, int tax_percent) {

        double tip = Math.round((tip_percent * .01) * meal_cost);
        double tax = Math.round((tax_percent * .01) * meal_cost);
        int total_cost = (int)(meal_cost + tip + tax);
        System.out.println(total_cost);
    }
 
PREVIOUS NEXT
Tagged: #calculate #tip #sales #tax #function
ADD COMMENT
Topic
Name
6+8 =