-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask11.cpp
More file actions
40 lines (37 loc) · 853 Bytes
/
Copy pathTask11.cpp
File metadata and controls
40 lines (37 loc) · 853 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
31
32
33
34
35
36
37
38
39
40
#include<iostream>
using namespace std;
bool input(int & a,float &b){
cout<<"Enter Cost of the meal : ";
cin>>a;
cout<<" Enter tax rate : ";
cin>>b;
if(a>0)
return 1;
else {
return 0;
}
}
float percnt(int a,float b){
return ((b*a)/100);
}
void display(int a,float b,float c){
cout<<"Cost of The meal : "<<a<<endl;
cout<<"Tax rate of The meal : "<<b<<endl;
cout<<"Tip rate of The meal : "<<c<<endl;
cout<<"Total cost of the meal : "<<(a+b+c)<<endl;
}
int main(){
int c_meal=0;
float t_rate=0;
float tip=20.0;
if(!input(c_meal,t_rate)){
cout<<"Invalid input \n ";
return 0;
}
float rate=0;
rate= percnt(c_meal,t_rate);
float tiprate=0;
tiprate=percnt(c_meal,tip);
display(c_meal,rate,tiprate);
return 0;
}