I can't figure out how to get my output formatted the way I would like. I tried to find info online and it wasn't exactly what I was looking for. Here is my code below. The point being to return a tip amount. The code works, my only problem is it returned four decimals places instead of two. So, I tried to format it, but now I'm getting errors.
Don't use %1.2f. That means one character with two after the decimal point. If you want to print 123.45 and you are sure you aren't going to have any negative numbers, you want three digits before the decimal point, one decimal point and two after, making six: %6.2f
Also don't use doubles for money. Either denominate alll amounts in ¢ and use integer arithmetic, or use BigDecimal.