-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday-2-operators.java
More file actions
31 lines (25 loc) · 963 Bytes
/
day-2-operators.java
File metadata and controls
31 lines (25 loc) · 963 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
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(); // original meal price
int tipPercent = scan.nextInt(); // tip percentage
int taxPercent = scan.nextInt(); // tax percentage
scan.close();
// Write your calculation code here.
double tip;
double tax;
double finalCost;
tip = tipPercent * mealCost / 100;
tax = taxPercent * mealCost / 100;
finalCost = mealCost + tip + tax;
// cast the result of the rounding operation to an int and save it as totalCost
int totalCost = (int) Math.round(finalCost);
// Print your result
System.out.println("The total meal cost is " + totalCost + " dollars.");
}
}