Originally Posted by copeg
Use the tags [highlight=java] your code [/highlight] .
Use [console] Your output [/console] for your output.
Use [exception] Exceptions/errors [/exception] for errors and exceptions that you might get.
Your code doesn't make sense here:
if (p >= 0)
pennies = p;
System.out.println("Please enter a numer greater than zero!");
You accept 0 in the if , but you tell them to enter a number greater than 0 if they enter something negative when you do the println in the else.
You seem to be doing the same thing with the nickels.
Note: Your set methods don't really rectify the issue if you enter a negative number. Hence, if you entered a negative, it would not fix it.
I think I may see something with your code that might be an issue.
I'm not sure if you want to start with one penny, one nickel, one dime, and one quarter, or if you are trying to set the values of penny, nickel, dime, quarter.
Assuming it's the latter, you'd be better off with a final constant value for each.
final double PENNY = 0.01;
final double NICKEL = 0.05;
final double DIME = 0.10;
final double QUARTER = 0.25;
You could make your pennies, nickels, dimes, and quarters now be of type int instead of double.
To get your total, just multiply your penny count by PENNY, your nickel count by NICKEL, and the same with dimes and quarters.