Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. public class DoWhile {
  2. public static void main (String[] args ){
  3. System.out.print("x = ");
  4. int i=0,x=0;
  5. do {
  6. if (((++i % 2) == 0) && (i<20)){
  7. System.out.print(i + " + ");
  8. x += i;
  9. }
  10. else if (i==20) {
  11. System.out.print(i);
  12. x += i;}
  13. }
  14. while(i<20);
  15. System.out.println("\nx = " + x);
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement