In: Computer Science
If (x> 1) && ( y <11)
Display statement
else
Display nothing
2. Suppose x is 1 and y is 10. What is the output of the following code?
If (x> 1) || ( y <11)
Display statement
Else
Display nothing
3. Write a java program that prints 1 to infinite numbers.
4. The following program is supposed to write out the integers 1, 2, 3, and 4. Decide what should go in the blanks.
public class Counter { public static void main (String[] args) { int count ; count = (blank) ; while ( count (blank) 4 ) { System.out.println( count ); count = count + (blank) ; } } }
5. The following program is supposed to write out the integers 2, 1, 0, -1 . Decide what should go in the blanks.
public class Counter3 { public static void main (String[] args) { int count ; count = (blank) ; while ( count >= (blank) ) { System.out.println( count ); count = count - (blank) ; } } }
6. The idea of a ______________ controlled loop is that there is a special value that says when the loop is done.
1. Suppose x is 1 and y is 10 (x> 1) && ( y <11) is False So, It prints Display nothing Answer: Display nothing 2. Suppose x is 1 and y is 10 (x> 1) || ( y <11) is True So, It prints Display statement Answer: Display statement 3. //TestCode.java public class TestCode { public static void main(String[] args) { int i = 0; while(true){ System.out.println(i); } } } 4. public class Counter { public static void main (String[] args) { int count ; count = 1 ; while ( count <= 4 ) { System.out.println( count ); count = count + 1 ; } } } 5. public class Counter3 { public static void main (String[] args) { int count ; count = 2 ; while ( count >= -1 ) { System.out.println( count ); count = count - 1 ; } } } 6. The idea of a sentinel controlled loop is that there is a special value that says when the loop is done.