# HackerRank Solutions – 30 Days of Code – Day 2

HackerRank Solutions – 30 Days of Code – Day 2

Objective
In this challenge, you’ll work with arithmetic operators. Check out the Tutorial tab for learning materials and an instructional video!

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) for a meal, find and print the meal’s total cost.

Note: Be sure to use precise values for your calculations, or you may end up with an incorrectly rounded result!

Input Format

There are lines of numeric input:
The first line has a double, (the cost of the meal before tax and tip).
The second line has an integer, (the percentage of being added as tip).
The third line has an integer, (the percentage of being added as tax).

Output Format

Print The total meal cost is totalCost dollars., where is the rounded integer result of the entire bill ( with added tax and tip).

Sample Input

12.00
20
8


Sample Output

The total meal cost is 15 dollars.


Explanation

Given:
mealcost=12 : tippercent=20 : taxpercent=8

Calculations:
tip=12*(20/100)=2.4
tax=12*(8/100)=0.96

tc=mc+tip+tax=12+2.4+.096=15.36

We round to the nearest dollar (integer) and then print our result:

The total meal cost is 15 dollars.

PROGRAM:


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main() {
float mc,tp,tx,tc;
int tip,tax,l,m;
scanf(“%f\n%d\n%d”,&mc,&tip,&tax);
tp=mc*tip/100;
tx=mc*tax/100;
tc=mc+tp+tx;
l=tc;
m=(tc*100)-(l*100);
l=(m>=50)?l+1:l;
printf(“The total meal cost is %d dollars.”,l);
return 0;
}

OUTPUT:

Congratulations

You solved this challenge. Would you like to challenge your friends?

12.00
20
8
The total meal cost is 15 dollars.
Success
Commment your doubts below:::