Sort by

recency

|

3416 Discussions

|

  • + 0 comments

    Anyone knows why correct solutions are not awarded with points nor marked as solved? (it is said that submissions take longer, but actually they are not taken)

  • + 0 comments

    In python:

    def solve(meal_cost, tip_percent, tax_percent):
        """
        Prints the calculated value, rounded to the nearest integer.
        :param meal_cost:
        :param tip_percent:
        :param tax_percent:
        :return: The function returns nothing.
        """
        tip = (meal_cost / 100) * tip_percent
        tax = (tax_percent / 100) * meal_cost
        total_cost = meal_cost + tip + tax
        print(int(round(total_cost)))
    
  • + 0 comments

    In the parameterised function define the formula, below is the code:

    function solve(meal_cost, tip_percent, tax_percent) { // Write your code here // Calculate tip and tax let tip = meal_cost * (tip_percent / 100); let tax = meal_cost * (tax_percent / 100);

    // Total cost
    let totalCost = meal_cost + tip + tax;
        }
    
    // Round to nearest integer and print
    console.log(Math.round(totalCost));
    

    }

  • + 0 comments

    Using explicit type casting to convert double into an int

    double tip = meal_cost/100*tip_percent; double tax = meal_cost/100*tax_percent;

    int total_cost =  (int)(meal_cost+tip+tax);
    System.out.println(total_cost);
    
  • + 0 comments

    1 liner in java (Split in 2 lines for understanding)

    int total = (int) Math.round( meal_cost * (1 + ( (double)tip_percent / 100) + ( (double)tax_percent / 100)));
    System.out.println(total);