SabirSazzad

Hacker rank day 2

Oct 30th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. #include <stdio.h>
  2. int main ()
  3. {
  4.     double meal,cost1,tipA,taxA;
  5.     int tip,tax,cost2;
  6.     double num = 23.345;
  7.  
  8.     scanf("%lf",&meal);
  9.     scanf("%d %d",&tip,&tax);
  10.  
  11.     tipA = meal * ((tip+0.00)/100);
  12.     taxA = meal * ((tax+0.00)/100);
  13.     cost1 = meal + tipA + taxA;
  14.  
  15.     int intpart = (int)cost1;
  16.     double decpart = cost1 - intpart;
  17.  
  18.     if(decpart > 0.5)
  19.     {
  20.         intpart = intpart + 1;
  21.  
  22.     }
  23.     printf("The total meal cost is %d dollars.",intpart);
  24.  
  25.     return 0;
  26. }
Add Comment
Please, Sign In to add comment