homework question is-----Write code that tests the variable x to determine whether it is greater than 0. If x is greater than 0, the code should test the variable y to determine whether it is less than 20. If y is less than 20, the code should assign 1 to the variable z. If y is not less than 20, the code should assign 0 to the variable z.
What i have at the moment is
import javax.swing.JOptionPane;
public class jjjd {
public static void main(String[] args) {
int x=0;
String input;
input=JOptionPane.showInputDialog("Enter a number for x");
x=Integer.parseInt(input);
if (x>0)
if (y<20)
{ (z==1);
}
else
{
z==0;
}
}
}
}
-------------------------------------------- EDIT import javax.swing.JOptionPane; public class jjjd {
public static void main(String[] args) {
int x=0;
String input;
input=JOptionPane.showInputDialog("Enter a number for x");
x=Integer.parseInt(input);
if (x>0) {
if (y<20)
{(z=1);}
}
else
{
z=0;
}
}
}
thats my new code!
the error im getting is the (z=0) under the else is "not a statement"
To assign a value to a variable you use = not ==