I have a problem for my return in the output



My program doesnt give me the output i expect it to give back. for the
total value of the coins it doesnt give me the total.
it just give a Zero as total value.
i would like you to help me solve it . Thanks in advance.


public class Coins {


private static final int NICKEL = 5;
private static final int DIME = 10;
private static final int QUARTER = 25;
private static final int PENNY = 1;
private int Quart;
private int Nick;
private int Dim;
private int Pen;
private int Total;
private int NoP;
private int NoN;
private int NoD;
private int NoQ;


public Coins(int P, int N, int D, int Q)
{
NoP = P ;
NoN = N ;
NoD = D ;
NoQ = Q ;
}

public void addCoins (String Co, int C)
{if (Co.equalsIgnoreCase ("PENNIES"))
{

NoP = NoP + C;

}
else if (Co.equalsIgnoreCase ("QUARTERS"))
{
Co = "Quarter";

NoQ = NoQ +C;

}
else if (Co.equalsIgnoreCase ("NICKELS"))
{
Co = "Nickel";

NoN =NoN +C;

}
else if (Co.equalsIgnoreCase ("DIMES"))
{
Co= "Dime";

NoD = NoD +C;

}

}


public void getPennyValue()
{
Pen = (NoP*PENNY);

}
public void getNickelValue()
{
Nick= (NICKEL*NoN);

}
public void getQuarterValue()
{
Quart = (QUARTER *NoQ);

}
public void getDimeValue()
{
Dim = (DIME*NoD);

}
public int getTotalValue()
{
Total = Dim + Nick + Pen + Quart;
return Total ;
}
public String toString() {
String str = "[";
str = str + "Number of penny = " + NoP + ", Number of Nickel = " +
NoN + ", Number of Dime = " + NoD +", Number of Quarter = " + NoQ + ",
Total Value = " + Total +"]";
return str;
}
}












.



Relevant Pages

  • Weird Problem in using MouseListener
    ... public class MouseInputTester extends java.applet.Applet { ... private int mouseX; ... public void mousePressed{ ... paint, ...
    (comp.lang.java)
  • Weird Problem in using MouseListener
    ... public class MouseInputTester extends java.applet.Applet { ... private int mouseX; ... public void mousePressed{ ... paint, ...
    (comp.lang.java.programmer)
  • Re: Multi-Threading problem
    ... private int seconds=0; ... private void secondsThread() { ... final MyClock myClock=new MyClock; ... public void run ...
    (comp.lang.java.programmer)
  • Cant compile (text to graphic window)
    ... I get the following error message when I try to compile the code below: ... {private int width; ... public void paintComponent ...
    (comp.lang.java.help)
  • Re: Problems adding a timer
    ... > private Button PushButton1; ... > public void paint{ ... > private int x; ...
    (comp.lang.java.programmer)