Computer Science, asked by abhijeetminz00, 2 months ago

Write a program using function to print 20 terms of series 3n + 2. Your program shall terminate as
soon as multiple of 4 is encountered. Write in Java.​

Answers

Answered by kajalpal1975
0

Answer:

public class Main {

public void printSeries() {

for (int i = 1; i <= 20; i++) {

int val = 3*i+2;

if (val % 4 == 0) {

System.out.println("Multiple of 4 encountered");

break;

} else {

System.out.println(val);

}

}

}

public static void main(String[] args) {

new Main().printSeries();

}

}

Please mark me as the brainliest.

Similar questions