import javax.swing.*; public class EvenNums { public static void main(String[]ar
ID: 3611593 • Letter: I
Question
import javax.swing.*;public class EvenNums
{
public static void main(String[]args)throws Exception
{
int response = 0;
while (response ==0)
{
String word = JOptionPane.showInputDialog(null,"Type in an integer");
String word1 = JOptionPane.showInputDialog(null,"Type in a second integer");
int num1 =Integer.parseInt(word);
int num2 =Integer.parseInt(word1);
int a;
String numbers = "";
for(a = num1;a<= num2; a++)
{
if(a%2 == 0);
numbers += ""+ a + " ";
}
JOptionPane.showMessageDialog(null,"The even numbers between "+ num1 + " and" + num2+ " are " +numbers);
response = JOptionPane.showConfirmDialog(null,"Do you want torepeat?");
}
}
}
I don't know how to print even numbers, can you help?
import javax.swing.*;
public class EvenNums
{
public static void main(String[]args)throws Exception
{
int response = 0;
while (response ==0)
{
String word = JOptionPane.showInputDialog(null,"Type in an integer");
String word1 = JOptionPane.showInputDialog(null,"Type in a second integer");
int num1 =Integer.parseInt(word);
int num2 =Integer.parseInt(word1);
int a;
String numbers = "";
for(a = num1;a<= num2; a++)
{
if(a%2 == 0);
numbers += ""+ a + " ";
}
JOptionPane.showMessageDialog(null,"The even numbers between "+ num1 + " and" + num2+ " are " +numbers);
response = JOptionPane.showConfirmDialog(null,"Do you want torepeat?");
}
}
}
I don't know how to print even numbers, can you help?