/* CSC110 Assignment:_Lab04.java__ Programmer: Phillip Sherman Due Date: 2/13/12 Points: 35 Description of Application: Four methods (harmonic, sum, triangle, parellelogram) Description of Inputs: Class constants N, SIZE, HEIGHT Description of Outputs: '*', ' ', or intergers */ class Lab04 { //Class constants required for modifying output of various methods // N is used public static final int N = 5; public static final int SIZE = 1; public static final int HEIGHT = 1; public static void main (String[] args) { harmonic(); sum(); } //Method for printing sum of harmonic series public static void harmonic () { //Declare Variable Double 'sum' to hold the harmonic series calculation double sum=0; for (int i=1; i<=N; i++) { // i is used for Denominator of fraction (1/i) // each run through loop adds the fraction to container 'sum' sum += 1.0/i; } //printing Total value of 'sum' based upon CONSTANT N System.out.println("Harmonic to " + N + "= " + sum); } //method for printing sum [Rules : Odd Integers up to N; //sum of first N positive odd integers] public static void sum () { //Declare variables 'sum1' & 'sum2' for //holding the sum amounts of the required calculations //'sum 1' : Is for holding the computation of the sum of // ODD integers up to N. int sum1=0; int sum2=0; for (int i=1; i<=N; i+=2) { sum1 += i; } for (int j=1; j<=N; j++) { for (int k=1; k<=N; k+=2) { sum2 += k; } } System.out.println(sum1); System.out.println(); System.out.println(sum2); } //method for printing a triangle of spaces & * using SIZE constant to //format the output size public static void triangle () { } //method for printing a parallelogram of spaces & * using SIZE constant to //format the output size public static void parallelogram () { } }