The waitstaff at a restaurant would like to determine the percentage (20%?, 15%?) left as tip by each customer. For comparison, the staff would also like to see how much the standard tip should be for a bill (e.g., $20 on $100).
left as tip and standard tip amount to be based on a customer’s total bill.
//percentage.cpp
//tip calculator
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
double getTipPercentage(double total);
int main(){
int total;
cout<<"Enter total bill to calculate tip: ";
cin>>total;
cout<<"Total :"<<total<<'\n'
<<"Tip: "<<getTipPercentage(total)<<endl;
return 0; //indicates success
}//end main
double getTipPercentage(double total){
double tip;
tip=total*0.20;
return tip;
}//end function getTipPercentage
Eyenrique-MacBook-Pro:Study Eyenrique$ ./percentage
Enter total bill to calculate tip: 120
Total :120
Tip: 24