Results 1 to 6 of 6

Thread: Little Help

  1. #1
    IWanna4get is offline Member
    Join Date
    Sep 2009
    Posts
    7
    Rep Power
    0

    Default Little Help

    I'm new to java >.>
    i seem to be having a problem in having a program in money denomination i'm suppose to use while loop the process is complete and no errors but the out put solution is wrong like when i type 800 it goes

    1000:0 500:1 200:-0 100:6

    which is weird :p


    any advice is open and i'll keep working on the money denomination thingy :D

    also a character identifier ex: i typed Hello 45!!!
    output:
    H-Consonant Letter
    e-vowel letter
    l-Consonant Letter
    l-Consonant Letter
    o-vowel letter

    4-even number
    5-odd number

    !-especial character
    !-especial character
    !-especial character

    i dunno how to use an array and the tutorials i'm reading are not making any sense -.-
    Last edited by IWanna4get; 09-01-2009 at 02:34 PM. Reason: didn't make the thing look right :D

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Does this tutorial make any sense?

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    The crystal ball is in the shop, so it's hard for me to discern what is presently wrong with your code. Why not post it here?

  4. #4
    IWanna4get is offline Member
    Join Date
    Sep 2009
    Posts
    7
    Rep Power
    0

    Default

    import javax.swing.*;
    import java.text.*;
    public class money{
    public static void main(String[]args){
    DecimalFormat formatter = new DecimalFormat("#0");
    String P="";
    double p=0.00;
    double a=0;
    double b=0;
    double c=0;
    double d=0;
    double e=0;
    double f=0;
    double g=0;
    double h=0;
    double i=0;
    double j=0;
    double k=0;
    double l=0;
    double m=0;
    double n=0;
    do{
    P=JOptionPane.showInputDialog(null,"Enter Value:");
    p=Double.parseDouble(P);
    while(p>999){
    a=(p-(p%1000))/1000;
    {break;}}while(p>499){
    b=((p-(a*1000))-(p%500))/500;
    {break;
    }}while(p>199){
    c=((p-(a*1000))-(p%200))/200;
    {break;}}
    while(p>99){
    d=((p-(b*500)-(c*200)))/100;
    {break;}}

    JOptionPane.showMessageDialog(null,"You Have\n1000= "+(formatter.format(a))+ "\n500= "+(formatter.format(b))+"\n200= "+(formatter.format(c))+"\n100= "+(formatter.format(d)));
    }while(JOptionPane.showConfirmDialog(null,"Again?" )==0);
    }


    }

    try 500 or 600
    it's wrong the decimal formatter is rounding it off >.<

    sadly i deleted the file with the 200 since its not getting fix,, how can u remove the decimal without rounding it off?
    Last edited by IWanna4get; 09-01-2009 at 05:44 PM. Reason: update :D

  5. #5
    senorbum is offline Member
    Join Date
    Aug 2009
    Posts
    76
    Rep Power
    0

    Default

    So is this program trying to calculate which of the 'bills' to give back as change or something?

    You really should label things with readable/logical names. Using letters is bad practice, unless you are doing a simple loop and using it as an iterator or something...

  6. #6
    IWanna4get is offline Member
    Join Date
    Sep 2009
    Posts
    7
    Rep Power
    0

    Default

    This program is a money denominator ex:

    i input 5600

    output: you have
    1000=5
    500=6
    200=0
    100=1

    in short it shows what the value is made of (the value is currency :p)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •