This is hackerrank question (30 day code) in which we have to find the total meal cost
For this we have given meal price (base cost of a meal), tip percent (the percentage of the meal price being added as tip), and tax percent (the percentage of the meal price being added as tax) for a meal, we have to find the total meal cost in integer
Here is it is Sample input
12.00
20
8
Sample Output is
15
Solution
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Operators {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
double meal_Cost = scan.nextDouble(); // original meal price in double
int tip_Percent = scan.nextInt(); // tip percentage in integer
int tax_Percent = scan.nextInt(); // tax percentage in integer
// Calculate Tax and Tip:
double tip = meal_Cost * tip_Percent / 100;
double tax = meal_Cost * tax_Percent / 100;
// cast the result of the rounding operation to an int and save it as total_Cost
int total_Cost = (int) Math.round(meal_Cost + tax + tip);
System.out.println( total_Cost);
}
}
Hope you guys enjoy this Code, Thank You
Happy Coding!