-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoperators.text
More file actions
30 lines (21 loc) · 965 Bytes
/
operators.text
File metadata and controls
30 lines (21 loc) · 965 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
/*Given the meal price (base cost of a meal),
tip percent (the percentage of the meal price being added as tip),
and tax percent (the percentage of the meal price being added as tax),
find and print the meal's total cost */
//operators
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();
double tip = (mealCost*tipPercent)/100;
double tax = (mealCost*taxPercent)/100;
// cast the result of the rounding operation to an int and save it as totalCost
int totalCost = (int) Math.round(mealCost+tip+tax);
System.out.println("The total meal cost is "+totalCost+" dollars.") ;
}
}