Power

Run Settings
LanguageJava
Language Version
Run Command
import java.util.Scanner; class Main { public static void main(String[] args) { //title block System.out.println(" _______ _______ _ _ _______ ______ "); System.out.println("| || || | _ | || || _ | "); System.out.println("| _ || _ || || || || ___|| | || "); System.out.println("| |_| || | | || || |___ | |_||_ "); System.out.println("| ___|| |_| || || ___|| __ |"); System.out.println("| | | || _ || |___ | | | |"); System.out.println("|___| |_______||__| |__||_______||___| |_|"); System.out.println(" By Hai Binh Nguyen\n"); Scanner input = new Scanner(System.in);//scanner for the input System.out.print("What is your base?"); int base = input.nextInt();//input the base System.out.println("\nWhat is your exponent?"); int exponent = input.nextInt();//input the exponent for(int i = 0; i<=exponent; i++){//loop base on the exponent input System.out.println(base +superscript(String.valueOf(i))+"=" + Math.pow(base,i));//the result } } public static String superscript(String s) {//superscript class s = s.replaceAll("0", "⁰"); s = s.replaceAll("1", "¹"); s = s.replaceAll("2", "²"); s = s.replaceAll("3", "³"); s = s.replaceAll("4", "⁴"); s = s.replaceAll("5", "⁵"); s = s.replaceAll("6", "⁶"); s = s.replaceAll("7", "⁷"); s = s.replaceAll("8", "⁸"); s = s.replaceAll("9", "⁹"); return s; } }
Editor Settings
Theme
Key bindings
Full width
Lines