// CIS 757/790                                    PROF. AUCIELLO
// (expo.java)
/*      Topics:

         input from keyboard
         formatting printing
         Math.pow function (method)

Output: C:\CoreJavaBook>java javapr04 Enter base: 2 Enter exponent: 16 2 raised to 1 = 2 2 raised to 2 = 4 2 raised to 3 = 8 2 raised to 4 = 16 2 raised to 5 = 32 2 raised to 6 = 64 2 raised to 7 = 128 2 raised to 8 = 256 2 raised to 9 = 512 2 raised to 10 = 1024 2 raised to 11 = 2048 2 raised to 12 = 4096 2 raised to 13 = 8192 2 raised to 14 = 16384 2 raised to 15 = 32768 2 raised to 16 = 65536
Psuedo-code for program: 1. start off with a statement that links to the corejava libraries. 2. define the program internal name -- same as DOS name. keyword-access-modifier + container for program 2.5 main bracket begins. 3. statement containing 'main' method 3.5 minor bracket begins. 4. define b,e,y as integers. 5. read data from the console, name it 'b'. 6. input data from console, name it 'e'. 7. start a loop from 0 to the value of 'e', auto-incrementing by 1. 8. inside that loop, start inner-most bracket, print 1st part of line (no line feed) 9. use a method to determine exponentiated result, and format print it as 5 positions with 0 decimal places. 10. Write a blank line with a line feed. Advances to next line. End inner-most bracket. 11. Minor bracket ends. 12. Major bracket ends. for (y = 1; y <= e; y += 1) b = corejava.Console.readInt("Enter base: "); import corejava.*; class javapr04 { public static void main (String args[]) { int b,e,y; System.out.println(" "); } } } e = corejava.Console.readInt("Enter exponent: "); Format.print(System.out,"%5.0f", Math.pow(b,y)); { System.out.print(b + " raised to " + y + " = "); Following the Psuedo-code (English descriptions), write the Java Program, compile it, run it, and print our results for 100 points. */
Source Listing