-1

I have been trying to find a way to make my code which does exponents accept an input for E and X. I know that if I use the scanner util, it would make this possible. But so far, I haven't found a way to do that. If you could help that would be sweet, thanks!

import java.util.Scanner;

public class SimpleExponents {

public static void main(String[] args) {
    int e = 6; 
    int x = 4; 
    double result; 

    result = Math.pow(e,x);

    System.out.println( result );

}

}

SkytechCEO
  • 71
  • 1
  • 4

1 Answers1

2
Scanner scanner = new Scanner(System.in);
int e = Integer.parseInt(scanner.next());
int x = Integer.parseInt(scanner.next());

or

Scanner scanner = new Scanner(System.in);
int e = scanner.nextInt();
int x = scanner.nextInt();
flakes
  • 12,841
  • 5
  • 28
  • 69