Computer Science Output Exercises 7

Ace your homework & exams now with Quizwiz!

public class Ex0718 { public static void main (String args[]) { for (int a = 1; a <= 3; a++) for (int b = 1; b <= 4; b++) System.out.println(a + " " + b); } }

1 1 1 2 1 3 1 4 2 1 2 2 2 3 2 4 3 1 3 2 3 3 3 4

public class Ex0719 { public static void main (String args[]) { for (int a = 1; a <= 6; a++) { for (int b = 1; b <= 5; b++) System.out.print(a * b + " "); System.out.println(); } } }

1 2 3 4 5 2 4 6 8 10 3 6 9 12 15 4 8 12 16 20 5 10 15 20 25 6 12 18 24 30

public class Ex0709 { public static void main (String args[]) { int x = 100; int y = 101; if (x > y) System.out.println("Hello"); else System.out.println("Goodbye"); } }

Goodbye

public class Ex0708 { public static void main (String args[]) { int x = 100; int y = 100; if (x == y) System.out.println("Hello"); } }

Hello

public class Ex0710 { public static void main (String args[]) { int x = 100; int y = 101; if (x < y) System.out.println("Hello"); else System.out.println("Goodbye"); } }

Hello

public class Ex0717 { public static void main (String args[]) { for (int a = 1; a <= 7; a++) for (int b = 1; b <= 2; b++) System.out.println("Hello"); } }

Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello

public class Ex0707 { public static void main (String args[]) { int x = 100; int y = 50; if (x == y) System.out.println("Hello"); } }

No Output

public class Ex0702 { public static void main (String args[]) { for (int x = -1; x <= 8; x+=3) System.out.println("x = " + x); } }

X= -1 X= 2 X= 5 X= 8

public class Ex0703 { public static void main (String args[]) { for (double x = 0; x < 4; x+=0.5) System.out.println("x = " + x); } }

X= 0.0 X= 0.5 X= 1.0 X= 1.5 X= 2.0 X= 2.5 X= 3.0 X= 3.5

public class Ex0705 { public static void main (String args[]) { for (int x = 1; x < 100; x*=3) System.out.println("x = " + x); } }

X= 1 X= 3 X= 9 X= 27 X= 81

public class Ex0701 { public static void main (String args[]) { for (int x = 10; x <= 15; x++) System.out.println("x = " + x); } }

X= 10 X= 11 X= 12 X= 13 X= 14 X= 15

public class Ex0714 { public static void main (String args[]) { int x = 10; int y = 20; while (x > y) { x++; y--; } System.out.println("x = " + x); System.out.println("y = " + y); } }

X= 10 X= 20

public class Ex0704 { public static void main (String args[]) { for (int x = 100; x >= 50; x-=10) System.out.println("x = " + x); } }

X= 100 X= 90 X= 80 X= 70 X= 60 X= 50

public class Ex0715 { public static void main (String args[]) { int x = 10; int y = 20; do { x++; y--; } while (x > y); System.out.println("x = " + x); System.out.println("y = " + y); } }

X= 11 Y= 19

public class Ex0712 { public static void main (String args[]) { int x = 0; int y = 0; while (x <= 10) { y = x + 3; x = y + 2; } System.out.println("x = " + x); } }

X= 15

public class Ex0711 { public static void main (String args[]) { int x = 5; int y = 15; while (x < y) { x = y + 2; y = x - 2; } System.out.println("x = " + x); } }

X= 17

public class Ex0706 { public static void main (String args[]) { for (int x = 200; x >= 25; x/=2) System.out.println("x = " + x); } }

X= 200 X= 100 X= 50 X= 25

public class Ex0713 { public static void main (String args[]) { int x = 0; int y = 0; while (x <= 20) { x++; y = x * 3; } System.out.println("x = " + x); System.out.println("y = " + y); } }

X= 21 X= 63


Related study sets

Series 66: Uniform Securities Act Quiz 3

View Set

Health 1-Chapter 10: Nutrition Basics

View Set

VN34: Maternal & Pediatric Nursing Theory

View Set

Disease Surveillance and Monitoring Systems

View Set

envsci 101 - Ozone in the atmosphere

View Set