Question

Write a value- return function which accepts the cost and the tip percentage (tipPercentage) as parameters....

Write a value- return function which accepts the cost and the tip percentage (tipPercentage) as parameters. The function must calculate the total meal amount that the customer must pay including the tip. Thus, values of tipPercentage can be 15 representing 15%, 18 representing 18%, and 20 representing 20%. An example of the cost of the meal with 15% is as follows : dinner cost * 0.15 + dinner cost.

Double costOfMeal (double price, int tipPercentag) {
0 0
Add a comment Improve this question Transcribed image text
Answer #1

C++ PROGRAM

#include<iostream>

using namespace std;

// implement costOfMeal()

double costOfMeal(double price,int tipPercentag)

{

return price*(tipPercentag/100.0)+price; // return total cost of Meals

}

int main()

{

// declare variables

double price;

int tip;

cout<<"Enter Price: "; cin>>price; // read price

cout<<"Enter Tip: "; cin>>tip; // read tip cost

cout<<costOfMeal(price,tip)<<endl; // calling costOfMeal() function

return 0;

}

OUTPUT-1

Enter Price: 55.5
Enter Tip: 18
65.49

OUTPUT-2

Enter Price: 65.5
Enter Tip: 18
77.29

OUTPUT-3

Enter Price: 95.3
Enter Tip: 20
114.36

Add a comment
Know the answer?
Add Answer to:
Write a value- return function which accepts the cost and the tip percentage (tipPercentage) as parameters....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT