total newbie still got problem

I am new to all this, and am still having problems with a simple program. How can I save the result of (i+j/k) as say "listprice1", in the end I want to do listprice1 + listprice2 + listprice3 and so on. where as at the moment I am doing this:

System.out.println("Total Cost " + ((i + j / k) + (l + n / m))); after my second list.

here is part of the programme

public class shoplist

{

public static void main(String[] args)

{

int i = 0;

int k = 100;

System.out.print("Cost of 1st item ");

System.out.print("Enter dollars -> ");

i = MyInput.readInt();

double j = 0.0;

System.out.print("Enter cents -> ");

j = MyInput.readDouble();

System.out.println("Cost input for 1st item is " + (i + j / k));

int l = 0;

int m = 100;

System.out.print("Enter dollars -> ");

l = MyInput.readInt();

double n = 0.0;

System.out.print("Enter cense -> ");

n = MyInput.readDouble();

System.out.println("Cost input for 1st item is " + (l + n / m));

System.out.println("Total Cost " + ((i + j / k) + (l + n / m)));

[1155 byte] By [red05a] at [2007-10-2 4:24:34]
# 1
listprice = (j /k +x whatever;)
CeciNEstPasUnProgrammeura at 2007-7-15 23:52:23 > top of Java-index,Java Essentials,Java Programming...
# 2
I have tried something like:listprice1 = (i + j / k);for the first part but it does not work.?
red05a at 2007-7-15 23:52:23 > top of Java-index,Java Essentials,Java Programming...
# 3

double listprice1;

listprice1=(i + j / k);

System.out.println("Cost input for 1st item is " + listprice1);

double listprice2;

listprice2=(l + n / m);

System.out.println("Cost input for 2nd item is " + listprice2);

System.out.println("Total Cost " + listprice1 + listprice2);

Does that help?

if you are going to have more than two items, or a variable amount of them you might think about creating an arraylist to hold the listprice values, and creating a method that does the l + n/m equation for you.

tiners506a at 2007-7-15 23:52:23 > top of Java-index,Java Essentials,Java Programming...
# 4
Thankyou!
red05a at 2007-7-15 23:52:23 > top of Java-index,Java Essentials,Java Programming...
# 5
if i, j, or k are an int you'll want to convert it/cast it to a double.. since you are storing it in a double. you didnt show us how those variables are initialized.
tiners506a at 2007-7-15 23:52:23 > top of Java-index,Java Essentials,Java Programming...