Basic tip calculator (input requested)

So, I'm new. i just started learning about classes and objects (still not sure how to implement them though.) and this is the first program i wrote with no help. Obviously its not very original. I have a couple of questions

1. How can I make this code reset/refresh so i can enter more than 1 request before the app closes?

2. In this case, is it dumb i've made a class for all those minor functions? would it be better to just store them all in main for this program?

3. Most importantly, is there anything I did that you guys would do differently? How can i simplify it?

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
#include "stdafx.h"
#include <iostream>
#include <string>

using namespace std;
//Creats a class
class tipCalc{
public:
	
	// Gets the price of the meal
	double meal(){
		double meal;
		cout << "How much was your meal?\n";
		cin >> meal;
		return meal;
	}
	// Gets tax
	double tax(){
		double tax;
		cout << "How much was the tax?\n";
		cin >> tax;
			return tax;
	}
	// Sets tip at 15% or 0.15
	double tip(){
		double tip = .15;
		return tip;
	}
};

int main()
{
	tipCalc tc;
	
	double pretotal;
	double total;
	
	
	
	

	pretotal = tc.meal() + tc.tax();
	total = (pretotal * tc.tip()) + pretotal;



	cout << "You're total is: " << total << endl;

	



}
1. How can I make this code reset/refresh so i can enter more than 1 request before the app closes?
Loops
2. In this case, is it dumb i've made a class for all those minor functions? would it be better to just store them all in main for this program?
Class is not needed here. A single function would do the trick.
3. Most importantly, is there anything I did that you guys would do differently? How can i simplify it?
If all you need is to calculate a tip a single function would be enough.
Otherwise (if it is a part of larger program or will be extended) I would make an order class, which would hold infomation about all ordered items, tax and tip and would be able to generate receipt.
Topic archived. No new replies allowed.