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.
Day 2: Operators
Day 2: Operators
+ 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 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 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 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); }
[deleted] + 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)
Load more conversations
Sort 3240 Discussions, By:
Please Login in order to post a comment