Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Need help with this code

  Asked By: Lourdes    Date: Jun 15    Category: Java    Views: 828
  

public class Stock
{

public static void main (String[] args)
{
int WBNo,
balance,
qtyIn,
qtyOut,
qtySold,

invNo;
double
unitPrice,
Total;

System.out.println("Enter the W/B Number: " + WBNo);
System.out.println("Enter the Qty In: " + qtyIn);
System.out.println("Enter the Qty Out: " + qtyOut);

balance = qtyIn - qtyOut;
System.out.println("Blance " + balance);

System.out.println("Enter the quantity sold: " + qtySold);
System.out.println("Enter the invoice number: " + invNo);
System.out.println("enter the unit price: " + unitPrice);
qtySold = parseInt(qtySold);
qtySold = qtySold * unitPrice;
System.out.println("Total is: " + Total);
}
}

I kneed to know why I am doing wroing shoud get and set statement, I
keed to know how to fix this problem

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Wilbur Hall     Answered On: Jun 15

First you need something to read input from. I always use a
BefferedReader. You need to import the java.io package and then dot
he following to read a String:

BufferedReader in = new BufferdReader(new
InputStreamReader(System.in));
String s = in.readLine();

To get an int from a String:

int i = Integer.parseInt(s);

Hope this help. Sorry, but I didn't have time to redo your code. Just
integrate the above into your application.

 
Answer #2    Answered By: Chione Massri     Answered On: Jun 15

You are naive
where are value of all of the integer defined
you should input the value

 
Didn't find what you were looking for? Find more on Need help with this code Or get search suggestion and latest updates.




Tagged: