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.
Your code did not pass this test case.
Input (stdin)
12.00
20
8
Your Output (stdout)
The total meal cost is 15dollars.
Expected Output
The total meal cost is 15 dollars.
Compiler Message
Wrong Answer
My code as below :-
import java.util.;
import java.math.;
public class Arithmetic {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
double mealCost = scan.nextDouble(); // original meal price
int tipPercent = scan.nextInt(); // tip percentage
int taxPercent = scan.nextInt(); // tax percentage
scan.close();
// Write your calculation code here.
double tip = mealCost * tipPercent / 100 ;
// System.out.println("tip is" +tip);
double tax = mealCost * taxPercent / 100 ;
// Sytem.out.println("tax is" +tax);
double meal = mealCost + tip + tax;
// cast the result of the rounding operation to an int and save it as totalCost
int totalCost = (int) Math.round(meal);
System.out.println( "The total meal cost is " +totalCost +"dollars.");
// Print your result
}
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 2: Operators
You are viewing a single comment's thread. Return to all comments →
Can you please tell me the reason for this!
Your code did not pass this test case. Input (stdin) 12.00 20 8 Your Output (stdout) The total meal cost is 15dollars. Expected Output The total meal cost is 15 dollars. Compiler Message Wrong Answer
My code as below :-
import java.util.; import java.math.;
public class Arithmetic {
}