Homework 3 Solution 2

Outprint forintcolumn10columnrowcolumn systemoutprint

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: r Right! Very good."); answer = createQuestion(); } return answer; }//end method checkResponse }//end class Multiply 4.Triangle Printing This program successfully compiles and runs. public class TrianglePattern { public static void main(String args) { System.out.println("(a)"); for(int i = 1; i <= 10; i++) { for(int j = 1; j <= i;j++) System.out.print("*"); System.out.println(); } System.out.println("\n(b)"); for(int i = 10; i >= 1;i­­) { for(int j = 1; j <= i;j++) System.out.print("*"); System.out.println(); } System.out.println("\n(c)"); for(int row = 10; row >= 1;row­­) { for(int space = 10; space > row;space­­) {System.out.print(" ");} for(int column =1; column <= row;column++) System.out.print("*"); System.out.println(); } System.out.println("\n(d)"); for(int row = 10; row >= 1; row­­) { for(int space =1; space < row; space++) System.out.print(" "); for(int column = 10; column >= row; column­­) System.out.print("*"); System.out.println(); } } } 5.E...
View Full Document

This document was uploaded on 03/26/2014 for the course CSE 292 at CSU San Bernardino.

Ask a homework question - tutors are online