63 200
Assignments Done
99,3%
Successfully Done
In July 2018

Answer to Question #14870 in Java | JSP | JSF for Kaze

Question #14870
Write a program that, starting from value 1, outputs the first 20 positive integers that are divisible by 2, but are not divisible by 3
Expert's answer

public class PositiveInteger {

/**
& * @param args
& */
public static void main(String[] args) {
& // TODO Auto-generated method stub
& int count = 0;
& int num = 1;
& while (count < 20) {
& if (num % 2 == 0 && num % 3 != 0) {
& System.out.println(num);
& count++;
& }
& num++;
& }
}

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions