We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Tutorials
  3. 30 Days of Code
  4. Day 2: Operators
  5. Discussions

Day 2: Operators

Problem
Submissions
Leaderboard
Discussions
Editorial
Tutorial

Sort 3240 Discussions, By:

recency

Please Login in order to post a comment

  • 63ashfaque
    6 days ago+ 0 comments

    Kotlin

    val tip=(meal_cost/100)*tip_percent
    val tax=(tax_percent.toFloat()/100)*meal_cost
    val total=meal_cost+tip+tax
    println(Math.round(total))
    
    0|
    Permalink
  • joaogdcarvalho
    1 week ago+ 0 comments

    JavaScript

    function solve(meal_cost, tip_percent, tax_percent) {
        // Write your code here
        const RESULT = Math.round(meal_cost + ((meal_cost * tip_percent) / 100) + ((meal_cost * tax_percent) / 100));
        console.log(RESULT);
    }
    
    0|
    Permalink
  • janardhangowda11
    1 week ago+ 0 comments

    JAVA CODE

    public static void solve(double meal_cost, int tip_percent, int tax_percent) { // Write your code here double tip=meal_cost* tip_percent/100; double tax=tax_percent*meal_cost/100; System.out.println( Math.round (meal_cost +tip+tax)); }

    }

    0|
    Permalink
  • 2k20csbs22
    2 weeks ago+ 0 comments
    #include<stdio.h>
    int main()
    {
        int b;
        float c,a;
        scanf("%f%d%f",&a,&b,&c);
        float x=(a/100)*b;
        float y = (c/100)*a;
        float z = a+x+y;
        printf("%.f",z); 
    }
    
    0|
    Permalink
  • [deleted] 2 weeks ago+ 0 comments

    My attempt here; still not very comfortable with input calls, i.e, input.x, for all x (e.g. "strip" = x)-

    #!/bin/python3
    
    import math
    import os
    import random
    import re
    import sys
    
    #
    # Complete the 'solve' function below.
    #
    # The function accepts following parameters:
    #  1. DOUBLE meal_cost
    #  2. INTEGER tip_percent
    #  3. INTEGER tax_percent
    #
    
    def solve(meal_cost, tip_percent, tax_percent):
        # Write your code here
        int(meal_cost)
        int(tip_percent)
        int(tax_percent)
        bill = ( ((tip_percent * meal_cost)/100) + ((tax_percent * meal_cost)/100) + meal_cost )
        print (round(bill))
        return
    if __name__ == '__main__':
        
        meal_cost = float(input().strip())
    
        tip_percent = int(input().strip())
    
        tax_percent = int(input().strip())
    
        solve(meal_cost, tip_percent, tax_percent)
    
    0|
    Permalink
Load more conversations

Need Help?


View tutorial
View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy