Sort by

recency

|

3411 Discussions

|

  • + 0 comments

    c#

    double meal_cost = Convert.ToDouble(Console.ReadLine().Trim());

        Console.Write(Math.Round(meal_cost+ Convert.ToInt32(Console.ReadLine().Trim())*meal_cost/100 + Convert.ToInt32(Console.ReadLine().Trim())*meal_cost/100));
    
  • + 0 comments

    //Compute the tip and tax values

             double tipValue = (meal_cost/100) * tip_percent ;
       double taxValue = (meal_cost/100) * tax_percent ;
    

    // Compute the the cost of the meal

            double total = tipValue+taxValue+meal_cost;
    

    * //Rounding the result to nearest Integer*

             System.out.printf("%.0f",total);
    
  • + 0 comments

    here for rounding you can use Math.round or you can just add 0.5 to total for rounding value like: sout((int)(total + 0.5));

  • + 0 comments

    I put it all in one line. That way I wouldn't need to use extra variables. This is in C#.

    Console.WriteLine(Math.Round((meal_cost*(tip_percent/100f))+(meal_cost*(tax_percent/100f))+meal_cost));
    
  • + 0 comments

    void solve(double meal_cost, int tip_percent, int tax_percent) { double tip, tax; int total_cost; scanf("%lf", &meal_cost); scanf("%d", &tip_percent); tip = (tip_percent*meal_cost)/100; scanf("%d", &tax_percent); tax = (tax_percent*meal_cost)/100; total_cost = round(meal_cost+tip+tax); printf("%d", total_cost); }