Hacker Rank - Day 2 : Operators

                        Day 2 :Operators.

Solution In Java 8:

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Arithmetic {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        double mealCost = scan.nextDouble();
        int tipPercent = scan.nextInt();
        int taxPercent = scan.nextInt();
        scan.close();
        double tip = mealCost*((double)tipPercent/100);
        double tax = mealCost*((double)taxPercent/100);
        Double cost = (Double) mealCost + tip + tax ;
        int totalCost = (int) Math.round(cost);
        System.out.println("The total meal cost is "+totalCost+ " dollars.");
    
    
    }
}

Solution In Python 3:

mealCost = float(input())
tipPercent = float(input())
taxPercent = float(input())

Cost = mealCost + (tipPercent/100)*mealCost + (taxPercent/100)*mealCost
round(Cost)
print("The total meal cost is %d dollers."%Cost)


The Solution is Corrent But the Compiler at Hacker Rank Shows Wrong Answer '

Wll be back at this SOON :)

Share:

0 comments:

Post a Comment