plss help me solve this codes

to those expert in java programming, i am new to java and i encounter a problem within my codes. You see, the program is supposed to be counting multiple numbers of the items as well as its price too. But i only can input 1 price i'll give you the code if you all don't really mind

import javax.swing.JOptionPane;

public class disc {

public static void main (String[] args){

String bil=JOptionPane.showInputDialog(null,"Bilangan barang ialah","Bilangan",JOptionPane.QUESTION_MESSAGE);

int bil1=Integer.parseInt(bil);

double jumlah=0; //jumlah harga

double diskaun=0; //jumlah diskaun

double jum=0; //jumlah selepas diskaun

int i;

int b=1;

for (i=1; i<=bil1; i++){

String Har=JOptionPane.showInputDialog(null,"Harga barang ke-"+b,"Harga",JOptionPane.QUESTION_MESSAGE);

double harga=Double.parseDouble(Har);

jumlah=jumlah+harga;

b++;

if (bil1>=1000){

if (jumlah<=10.00)

diskaun=jumlah*0.21;

else

if ((jumlah>=10.01) && (jumlah<=100.00))

diskaun=jumlah*0.32;

else

diskaun=jumlah*0.43;

}

else

if ((bil1>=500) && (bil1<=999)){

if (jumlah<=10.00)

diskaun=jumlah*0.09;

else

if ((jumlah>=10.01) && (jumlah<=100.00))

diskaun=jumlah*0.15;

else

diskaun=jumlah*0.21;

}

else

if ((bil1>=100) && (bil1<=499)){

if (jumlah<=10.00)

diskaun=jumlah*0.05;

else

if ((jumlah>=10.01) && (jumlah<=100.00))

diskaun=jumlah*0.07;

else

diskaun=jumlah*0.09;

}

else

if ((bil1>=10) && (bil1<=99)){

if ((jumlah>=10.01) && (jumlah<=100.00))

diskaun=jumlah*0.02;

else

if (jumlah>=100.01)

diskaun=jumlah*0.05;

}}

jum=jumlah-diskaun;

JOptionPane.showMessageDialog (null,"Jumlah harga ialah RM" +jumlah +"Jumlah diskaun ialah RM" +diskaun +"Jumlah harga selepas diskaun ialah RM"+jum,"Jumlah",JOptionPane.INFORMATION_MESSAGE);

System.exit(0);

}}

plss help me solve the prob

[2202 byte] By [sarf2k4a] at [2007-11-26 18:12:00]
# 1
Just plopping your (unformatted, to boot) code here with a plea basically to just "fix it for me" isn't going to get you very far.
warnerjaa at 2007-7-9 5:44:44 > top of Java-index,Java Essentials,Java Programming...
# 2

When you post code, please use[code] and [/code] tags as described in [url=http://forum.java.sun.com/help.jspa?sec=formatting]Formatting tips[/url] on the message entry page. It makes it much easier to read.

Re-paste your code, formatted and indented, and be specific about what problems you're having.

jverda at 2007-7-9 5:44:44 > top of Java-index,Java Essentials,Java Programming...
# 3

I am having trouble understanding your code and question, partly to do with the formatting (as mentioned above), but also to do with the language barrier.

I don't know what I am being prompted for, and the variable names mean nothing to me, so translating these (even into broken English) would be a good start.

Secondly, you are saying you want two inputs (I think), but you only get to input bill once, this is because:

String bil= JOptionPane.showInputDialog(null,"Bilangan barang ialah","Bilangan",JOptionPane.QUESTION_MESSAGE);

is outside the FOR loop, so only run once. The only time you are asking for any input inside the loop is with:

String Har=JOptionPane.showInputDialog(null,"Harga barang ke-"+b,"Harga",JOptionPane.QUESTION_MESSAGE);

which is run several times.

If you want to take more than one ?bill?, you need to either implement another loop somewhere (either two separate loops or nested, depending what you are trying to do), or have another input dialog inside the loop.

I am sorry I cannot be more specific, this is only because I don't understand what you are trying to do.

abu5ea at 2007-7-9 5:44:44 > top of Java-index,Java Essentials,Java Programming...
# 4

import javax.swing.JOptionPane;

public class disc {

public static void main (String[] args){

String bil=JOptionPane.showInputDialog(null,"Bilangan barang ialah","Bilangan",JOptionPane.QUESTION_MESSAGE);

int bil1=Integer.parseInt(bil);

double jumlah=0; //jumlah harga

double diskaun=0; //jumlah diskaun

double jum=0; //jumlah selepas diskaun

int i;

int b=1;

for (i=1; i<=bil1; i++){

String Har=JOptionPane.showInputDialog(null,"Harga barang ke-"+b,"Harga",JOptionPane.QUESTION_MESSAGE);

double harga=Double.parseDouble(Har);

jumlah=jumlah+harga;

b++;

if (bil1>=1000){

if (jumlah<=10.00)

diskaun=jumlah*0.21;

else

if ((jumlah>=10.01) && (jumlah<=100.00))

diskaun=jumlah*0.32;

else

diskaun=jumlah*0.43;

}

else

if ((bil1>=500) && (bil1<=999)){

if (jumlah<=10.00)

diskaun=jumlah*0.09;

else

if ((jumlah>=10.01) && (jumlah<=100.00))

diskaun=jumlah*0.15;

else

diskaun=jumlah*0.21;

}

else

if ((bil1>=100) && (bil1<=499)){

if (jumlah<=10.00)

diskaun=jumlah*0.05;

else

if ((jumlah>=10.01) && (jumlah<=100.00))

diskaun=jumlah*0.07;

else

diskaun=jumlah*0.09;

}

else

if ((bil1>=10) && (bil1<=99)){

if ((jumlah>=10.01) && (jumlah<=100.00))

diskaun=jumlah*0.02;

else

if (jumlah>=100.01)

diskaun=jumlah*0.05;

}}

jum=jumlah-diskaun;

JOptionPane.showMessageDialog (null,"Jumlah harga ialah RM" +jumlah +"Jumlah diskaun ialah RM" +diskaun +"Jumlah harga selepas diskaun ialah RM"+jum,"Jumlah",JOptionPane.INFORMATION_MESSAGE);

System.exit(0);

}}

this program will read the Quantity of items purchased and the price for all those items and got discounts for specific prices range and the quantity of the items. I know i got problem at these codes after the for and the if command. But i think this is a low-level codes for you guys and most of the language in these are malaysian language

String Har=JOptionPane.showInputDialog(null,"Harga barang ke-"+b,"Harga",JOptionPane.QUESTION_MESSAGE);

harga=price

barang=item

diskaun=discount

jumlah=total amount

bil=quantity

sarf2k4a at 2007-7-9 5:44:44 > top of Java-index,Java Essentials,Java Programming...