Gratuity Calculator

Hi all Im supposed to create a program that designs a Tips class that calculates the gratuity on a restaurant meal. Its only class member variable, taxRate, should be set by a one-parameter constructor to whatever rate is passed to it when a Tips object is created. If no argument is passed, a default tax rate of .065 should be used. The class should have just one public function, computeTip. This function needs to accept two arguments, the total bill amount and the tip rate. It should use this information to compute the meal cost before any tax was added. It should then apply the tip rate to just the meal cost portion of the bill to compute and return the tip amount. Demonstrate the class by creating a program that creates a single Tips object, then loops multiple times to allow the program user to retrieve the correct tip among using various bill totals and desired tip rates.

So my issue I feel like I did the code correctly but my int main seems wrong. Im using visual studio so its pretty picky. Any idea on how to correct it?

Thanks

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
51
52
53
54
55
56
57
58
59
60
61
62
#include "stdafx.h"
#include <iostream>
using namespace std;

class Tips{
	private:
		double taxRate;

	public:
	double computeTip;
		Tips(double rate){
			if (rate<0)
				taxRate=.065;
			else{
				taxRate=rate;
			}
		}
		
		Tips(){
			taxRate=.065;
		}

		int computeTips(double, double);	
		


};

int Tips::computeTips(double bill, double tip){
			if (bill>0)
			double	billTotal = bill;
			else{
				cout << "Please enter a value greater than 0 as the bill total:" << endl;
				cin >> bill;
			}
			if (tip>0)
				double tipRate = tip;
			else{
				cout << "Please enter a value greater than 0 as the tip rate:" << endl;
				cin >> tip;
			}
			double mealCost;
			double billTotal;
			mealCost = billTotal - (billTotal * taxRate);
			double tipAmount;
			double tipRate;
			tipAmount=tipRate*mealCost;
			cout << "The amount you owe as a tip is $" << tip << endl;
			return tip;


}

int main ()
{
	Tips tip;
	tip.computeTip(100, 20);
	return 0;



}
tip.computeTip(100, 20); should be tip.computeTips(100, 20);
Topic archived. No new replies allowed.