Day 2: Operators Hackerrank Solution in Java
Do Check My Video Explanation:
Sample Input
12.00
20
8
Sample Output
15
Solution:
import java.io.*;import java.math.*;import java.security.*;import java.text.*;import java.util.*;import java.util.concurrent.*;import java.util.regex.*;
public class Solution {
// Complete the solve function below. static void solve(double meal_cost, int tip_percent, int tax_percent) { double tip=meal_cost*tip_percent/100; double tax=meal_cost*tax_percent/100; int totalCost=(int)Math.round(meal_cost+tip+tax); System.out.print(totalCost); }
private static final Scanner scanner = new Scanner(System.in);
public static void main(String[] args) { double meal_cost = scanner.nextDouble(); scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
int tip_percent = scanner.nextInt(); scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
int tax_percent = scanner.nextInt(); scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
solve(meal_cost, tip_percent, tax_percent);
scanner.close(); }}
Comments
Post a Comment