Write a program that prints all even numbers from 2 to 100inclusive. Should ask
ID: 3611427 • Letter: W
Question
Write a program that prints all even numbers from 2 to 100inclusive. Should ask if it wants to run again and ask for input(whichnumber to start/end with). Also, needs to be in JOptionPane This is what I have, but I don't know how to print only evennumbers. WILL GIVE BIG POINTS IF DONE CORRECTLY! public class EvenNums{
public static void main(String[]args)throws Exception
{
int num, testNum;
for(testNum = 2;testNum <= 100; ++testNum)
{
{
System.out.print(testNum + " is evenlydivisible by ");
for(num = 2; num< testNum; ++num)
if(testNum%num ==2)
System.out.print(num + "");
System.out.println();
if(testNum % 100== 0)
{
System.out.println("Press Enter tocontinue");
System.in.read(); System.in.read();
}
}
} } I am kind of confused. Please Help! Thanks! Write a program that prints all even numbers from 2 to 100inclusive. Should ask if it wants to run again and ask for input(whichnumber to start/end with). Also, needs to be in JOptionPane Also, needs to be in JOptionPane This is what I have, but I don't know how to print only evennumbers. WILL GIVE BIG POINTS IF DONE CORRECTLY! public class EvenNums
{
public static void main(String[]args)throws Exception
{
int num, testNum;
for(testNum = 2;testNum <= 100; ++testNum)
{
{
System.out.print(testNum + " is evenlydivisible by ");
for(num = 2; num< testNum; ++num)
if(testNum%num ==2)
System.out.print(num + "");
System.out.println();
if(testNum % 100== 0)
{
System.out.println("Press Enter tocontinue");
System.in.read(); System.in.read();
}
}
} } I am kind of confused. Please Help! Thanks! } I am kind of confused. Please Help! Thanks!
Explanation / Answer
please rate - thanks import javax.swing.*; public class EvenNums { public static void main(String[] args)throws Exception { int num, testNum,start=2,stop=100; String mess,response; int yesno; mess="The even numbers between "+start+" and "+stop+" are: "; for(;;) { num=0; for(testNum = start; testNumRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.