Help, I am killing myself trying to do this and I need help ASAP

I need help with this program it has to act like a cash register. The user will input an items price and then their payment. It will tell you the change and then tell you what kinda of change to use, see example below:
Use JOptionPane to take inputs from the user and display the results.
Example:
If the user enters
Amount Due = 5.52 // First Input from the User
Amount Given = 10.00 // Second Input from the User
Calculate the Balance Due
Balance Amount = $ 4.48
and display the balance due in denomination as (The following four lines will be ONE Output to the user)
$1 bill = 4 (4.00)
Quarters = 1 (0.25)
Dimes = 2 (0.20)
Pennies = 3 (0.03)
This last part, where you display the change that will be given back, ie: how many quarters, dimes, nickels, pennies is the part I am having problems with.
Can some one help? Please pardon my coding abilities, I am still learning how to do this and would really appreciate any help you can with my program.
Thanks in advance.
import javax.swing.*;
import java.text.*;
public class CashReg
{ //Start
public static void main (String [] args)
{ //Start Main
int count = 0;
char c1 = 0;
String price = null;
String payment = null;
String change = null;
boolean correct = false;
while(!correct)
{ //Start Loop
price = JOptionPane.showInputDialog (null,"Enter the amount of the item for purchase");
if (price.length() < 1) //Loop
JOptionPane.showMessageDialog (null, "You did not enter a purchase amount, try again please.");//Error message
payment = JOptionPane.showInputDialog (null,"Enter your payment amount.");
if (payment.length() < 1) //Loop
JOptionPane.showMessageDialog (null, "You did not enter a payment amount, try again please.");//Error message
else
correct = true; //Boolean to confirm that there are enough characters
for (int i=0; i<price.length(); i++)
if (Character.isUpperCase(price.charAt(i)))
count++;
} //End loop
// response = price - payment;
JOptionPane.showMessageDialog (null, "You item costs "+price+" and you payed "+payment+" and your change will be "+change);
System.exit(0);
} //End Main
} //End

OK, thanks for your help, but I need some more. I have the program running and showing the amount of change that is going to be returned. But I don't know how to display the kind of change. AKA, quarters, dimes, nickels and pennies. I am a programming idot, my teacher is letting us twist in the wind. He is not explaining the concepts behind any of this. You are saying the word "logic" and I don't know what that means. This assigment is due Monday, I just need some help with the last part. How to show the change. I am just plain lost. please help.
import java.text.DecimalFormat;
import javax.swing.*;
import java.text.*;
public class CashReg
{     //Start
     public static void main (String [] args)
     {          //Start Main
          int count = 0;
          char c1 = 0;
          String price = null;
          String payment = null;
          String change = null;
          boolean correct = false;
     while(!correct)
     {          //Start Loop
     price = JOptionPane.showInputDialog (null,"Enter the amount of the item for purchase");
          if (price.length() < 1)     //Loop
               JOptionPane.showMessageDialog (null, "You did not enter a purchase amount, try again please.");//Error message
               payment = JOptionPane.showInputDialog (null,"Enter your payment amount.");
          if (payment.length() < 1)     //Loop
               JOptionPane.showMessageDialog (null, "You did not enter a payment amount, try again please.");//Error message
          else
               correct = true; //Boolean to confirm that there are enough characters
for (int i=0; i<price.length(); i++)
          if (Character.isUpperCase(price.charAt(i)))
          count++;
     }     //End loop
//     response = price - payment;
float fPrice = Float.parseFloat(price);
float fPayment = Float.parseFloat(payment);
float fChange = fPayment-fPrice;
DecimalFormat df = new DecimalFormat ("#.00");
JOptionPane.showMessageDialog (null, "You item costs "+price+" and you payed "+payment+" and your change will be "+ df.format (fChange));
This is where I don't know what to put
     System.exit(0);
     }     //End Main
     }     //End
I am begging for help.

Similar Messages

Maybe you are looking for