Friday, September 30, 2016

// // Leave a Comment

Java Program To Print Table

The program below is the answer to Liang's Introduction to Java Programming (9th Edition) Chapter 2 Exercise 2.18.

/**
 *
 * @Author: Aghatise Osazuwa
 * Website: www.cscprogrammingtutorials.com
 *
 * Exercise 2.18 - Print a table
 *
 */ 

public class Ex02_18 {

    public static void main(String[] args) {
        
        // Display Program Information
        System.out.println("This Program Prints A Table.\n");
        System.out.println("\ta\tb\tpow(a, b)");
        System.out.println("\t" + 1 + "\t" + 2 + "\t" + (int) Math.pow(1, 2));
        System.out.println("\t" + 2 + "\t" + 3 + "\t" + (int) Math.pow(2, 3));
        System.out.println("\t" + 3 + "\t" + 4 + "\t" + (int) Math.pow(3, 4));
        System.out.println("\t" + 4 + "\t" + 5 + "\t" + (int) Math.pow(4, 5));
        System.out.println("\t" + 5 + "\t" + 6 + "\t" + (int) Math.pow(5, 6));
    }
}

Click here to see other solutions to Introduction to Java Programming.

0 comments:

Post a Comment


DISCLAIMER: Opinions expressed in comments are those of the comment writers alone and does not reflect or represent the views of the post author. We reserve the right to delete any post deemed inappropriate or offensive and/or spammy. Please do not use abusive words/hate speech.

I Appreciate your valuable Feedback. So, Please DO NOT SPAM - Spam comments will be deleted immediately.

Don't use brand name in name field and you're not allowed to use links in comments unless it's necessary. Such comments will be removed immediately.

Thanks.