
















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!

















Based on slides from Marty Stepp and Stuart Reges from http://www.buildingjavaprograms.com/
public class Stars1 { public static void main(String[] args) { lineOf13(); lineOf7(); lineOf35(); box10x3(); box5x4(); } public static void lineOf13() { for (int i = 1; i <= 13 ; i++) { System.out.print(""); } System.out.println(); } public static void lineOf7() { for (int i = 1; i <= 7 ; i++) { System.out.print(""); } System.out.println(); } public static void lineOf35() { for (int i = 1; i <= 35 ; i++) { System.out.print("*"); } System.out.println(); } ...
public static void
public static void main(String[] args) { printNumber(4, 9); printNumber(17, 6); printNumber(8, 0); printNumber(0, 8); } public static void printNumber( int number , int count ) { for (int i = 1; i <= count ; i++) { System.out.print( number ); } System.out.println(); } Output: 444444444 171717171717 00000000
// Prints a box of stars of the given size. public static void box(int width, int height) { line(width); for (int line = 1; line <= height - 2; line++) { System.out.print(""); for (int space = 1; space <= width - 2; space++) { System.out.print(" "); } System.out.println(""); } line(width); } } 16
public static void strange( int x ) { x = x + 1; System.out.println("1. x = " + x ); } public static void main(String[] args) { int x = 23; strange(x); System.out.println("2. x = " + x ); ... }
Clicker 2 - What is output by the following code?