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.
// cast the result of the rounding operation to an int and save it as totalCost
int totalCost = (int) Math.round(mealCost);
System.out.println("totalcost"+totalCost);
// Print your result
}
Day 2: Operators
You are viewing a single comment's thread. Return to all comments →
The below code is also giving as wrong answer but we are curious to know why it is wrong .. can any one help us in knowing that ...
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();
// System.out.println("tax is"+tax); mealCost=mealCost+tip+tax;