



























































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




























































Homework Problems
1. Try to declare meaningful variables of each type. Eg - a variable **named age should be a numeric type (int or float) not byte.
Homework Problems
import java.util.; public class Patterns { public static void main(String args[]) { int n = 5; int m = 4; for(int i=0; i<n; i++) { for(int j=0; j<m; j++) { System.out.print(""); } System.out.println(); } } }
3. import java.util.; public class Patterns { public static void main(String args[]) { int n = 4; for(int i=1; i<=n; i++) { for(int j=1; j<=i; j++) { System.out.print(""); } System.out.println(); } } }
4. import java.util.; public class Patterns { public static void main(String args[]) { int n = 4; for(int i=n; i>=1; i--) { for(int j=1; j<=i; j++) { System.out.print(""); } System.out.println(); } } }
6. import java.util.; public class Patterns { public static void main(String args[]) { int n = 5; for(int i=1; i<=n; i++) { for(int j=1; j<=i; j++) { System.out.print(j); } System.out.println(); } } }*
7. import java.util.; public class Patterns { public static void main(String args[]) { int n = 5; for(int i=n; i>=1; i--) { for(int j=1; j<=i; j++) { System.out.print(j); } System.out.println(); } } }*
9. import java.util.; public class Patterns { public static void main(String args[]) { int n = 5; for(int i=1; i<=n; i++) { for(int j=1; j<=i; j++) { if((i+j) % 2 == 0) { System.out.print(1+" "); } else { System.out.print(0+" "); } } System.out.println(); } } }*
Homework Problems (Solutions in next Lecture’s Video)