UsingMethods - } public static void printSquare(char...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
// File: UsingMethods.java // Author: Amber Settle // Purpose: To demonstrate how to use programmer-defined methods / import java.util.Scanner; i public class UsingMethods { public static void main(String[] args) { // Print a square with 5 row and 5 columns filled // with asterisks //printSquare('*', 5); //System.out.println(); // Print a square with 3 rows and 3 columns filled // with question marks //printSquare('?', 3); //System.out.println(); // Print the sum of 2 squared plus 3 squared //System.out.println("2^2 + 3^2 = " + sumOfSquares(2, 3)); //System.out.println(); //int sum = sumOfSquares(1, 2); //System.out.println("1^2 + 2^2 = " + sum);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } public static void printSquare(char symbol, int size) { for (int i = 1; i <= size; i++) { for (int j = 1; j <= size; j++) System.out.print(symbol); System.out.println(); } }// closes main // Prints a square filled with the indicated char, // with size rows and size columns //public static void printSquare(char symbol, int size) { //for (int i = 1; i <= size; i++) { // for (int j = 1; j <= size; j++) // System.out.print(symbol); // System.out.println(); } } // Returns a squared plus b squared (a^2 + b^2) //public static int sumOfSquares(int a, int b) { //int value = a*a + b*b; //return value; } }...
View Full Document

This note was uploaded on 03/05/2011 for the course CSCI 384 taught by Professor Drchan during the Spring '11 term at CA Health Sciences.

Page1 / 2

UsingMethods - } public static void printSquare(char...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online