-
Notifications
You must be signed in to change notification settings - Fork 858
Expand file tree
/
Copy pathDay2Operators.java
More file actions
31 lines (27 loc) · 919 Bytes
/
Copy pathDay2Operators.java
File metadata and controls
31 lines (27 loc) · 919 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
*
* Problem Statement-
* [Operators](https://www.hackerrank.com/challenges/30-operators/problem)
*
*/
package com.javaaid.hackerrank.solutions.thirtydaysofcode;
import java.util.Scanner;
/**
* @author Kanahaiya Gupta
*
*/
public class Day2Operators {
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 tC = mealCost + (mealCost * tipPercent) / 100 + (mealCost * taxPercent) / 100;
// cast the result of the rounding operation to an int and save it as totalCost
int totalCost = (int) Math.round(tC);
System.out.println("The total meal cost is " + totalCost + " dollars.");
// Print your result
}
}