File tree 2 files changed +40
-0
lines changed
2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ public class Arithmetic {
2
+
3
+ public static void main (String [] args ) {
4
+ Scanner scan = new Scanner (System .in );
5
+ double mealCost = scan .nextDouble (); // original meal price
6
+ int tipPercent = scan .nextInt (); // tip percentage
7
+ int taxPercent = scan .nextInt (); // tax percentage
8
+ scan .close ();
9
+
10
+ // Write your calculation code here.
11
+ double tip = ((mealCost *tipPercent )/100 );
12
+ double tax =((mealCost *taxPercent )/100 );
13
+ double numberToRoundHere = tip + tax + mealCost ;
14
+
15
+ // cast the result of the rounding operation to an int and save it as totalCost
16
+ int totalCost = (int ) Math .round (numberToRoundHere );
17
+
18
+ // Print your result
19
+ System .out .printf ("The total meal cost is %d dollars." ,totalCost );
20
+ }
21
+ }
Original file line number Diff line number Diff line change
1
+ import java .util .Scanner ;
2
+
3
+ public class Arithmetic {
4
+
5
+ public static void main (String [] args )
6
+ {
7
+ Scanner scan =new Scanner (Systen .in );
8
+ double mealcost =scan .nextDouble (); //orignal mealcost
9
+ int tipPercent =scan .nexInt (); //tip percent
10
+ int taxPercent =scan .nextInt (); //tax percent
11
+
12
+ //Calculations for bill amount
13
+ double tip =((mealcost *tipPercent )/100 );
14
+ double tax =((mealcost *taxPercent )/100 );
15
+ int totalcost =(int ) (tip +tax +mealcost ) ;
16
+ System .out .println ("Your total bill is of:" +totalcost );
17
+ }
18
+ }
19
+
You can’t perform that action at this time.
0 commit comments