hi , i have this problem, which i cannot figure it out. This problem has been day now,and reached does not seem to help. How do u pass an integer value form one class to the other class. Here my code. The integer that summited by the user which is stored in the "amt" and amt is converted to integer, that is amount. Then the amount would be call be the class counter, so that is will be calculated until it reach zero. Also i am beginner in Java.ty
import javax.swing.*;
class input
{
int amount, num;
String amt;
public void userInput ()
{
JFrame frame = new JFrame();
amt = JOptionPane.showInputDialog(frame, "How much would u like?");
num= Integer.parseInt(amt);
amount = num;
counter obj = new counter();
obj.numberCounter();
}
}
class counter extends input
{
public void numberCounter ()
{
input count = new input();
int soda=10;
if (soda==0){
System.out.println("Out of soft drink");
}
else if (count.amount >1 && count.amount <10 ){
while (count.amount >1 && count.amount <10 )
{
input objj = new input();
objj.userInput();
}
}else {
soda=soda - count.amount;
}
}
}
class Test
{
public static void main (String args[]){
System.out.println("Hi");
input objj = new input();
objj.userInput();
}
}