But I don't know what it is. I'm a student and this is my first (university) class in Java programming.
Basically, what I'm trying to do is write a simple tip calculator. The trouble is with how my instructor wants it done. He wants the user to be presented with this as the tip types:
1- 10%
2- 15%
3- 20%
4- 25%
and have the user input 1-4 instead of, say, "15" or "0.15". We haven't really done any examples like this in class so I'm not sure how to assign the 1-4 to each percentage. Complicating matters (and my math) is that we can only use integers; no double or float. I declared my variables as;
int tipRate1 = 5 + (1 * 5);
int tipRate2 = 5 + (2 * 5);
int tipRate3 = 5 + (3 * 5);
int tiprate4 = 5 + (4 * 5);
and the base tip rate is 5 + tip type * 5. I know the math is right, but I'm not sure how to assign the values 1-4 AND the equation without listing the tip types twice- once to assign the base tip rate equation and again to assign the input value to it. Does that make sense? Is there a way to combine that into one line per tip type so it looks cleaner and more efficient?
The other thing I'm having trouble with is how to get the tip amount. I know I have to do something like this;
(foodBill + barTab)*100 to get the bill total in cents and then somehow get it to calculate the tip in the same line without using decimals. My instructor wants to output as, for example, "Your tip should be __dollars and __cents." I'm not sure how to turn it back into dollars and have a remainder, much less output as words and not just as a number.
Anyways, it's not due until Feb 1st, but I've spent a lot of hours working on it for the last week and I've finally had to break down and seek some guidance. I'm getting a tad frustrated and feel like there's a simple solution I'm just not seeing. If anyone has some suggestions to point me in the right director, that would be fantastic!