-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path30 Days of Code: Day 2: Operators
50 lines (36 loc) · 1.49 KB
/
30 Days of Code: Day 2: Operators
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main()
{
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
double mealCost;
int tipPercent;
int taxPercent;
scanf("%lf %i %i", &mealCost, &tipPercent, &taxPercent);
float totalCost;
totalCost = mealCost/*mealWithoutTaxnTip*/ + mealCost*tipPercent/100/*tip*/ + mealCost*taxPercent/100/*tax*/;
printf("The total meal cost is %.0f dollars.", totalCost);
return 0;
}
/*
Objective
In this challenge, you'll work with arithmetic operators. Check out the Tutorial tab for learning materials and an instructional video!
Task
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.
*/