The Math Class | Sololearn: Learn to code for FREE!


The Math Class

Is there a reason I’m missing that this wouldn’t pass all 5 cases? // The Math Class - Java Code Coach import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(; int num1 = sc.nextInt(); int num2 = sc.nextInt(); double num3 = Math.pow(num1,num2); //your code goes here System.out.print(num3); } }

10/19/2020 7:08:36 PM

Roderick Davis

11 Answers

New Answer


Some problem having test case error in Java course. I've implementaed own power function that too failed in same test case 4th. Maybe bug report to sololearn can help


import java.util.Scanner; class Main { public static void main(String[] args) { Scanner read = new Scanner(; int num1 = read.nextInt(); int num2 = read.nextInt(); //Please Subscribe to My Youtube Channel //Channel Name: Fazal Tuts4U System.out.println(Math.pow(num1, num2)); } }


Theres no reason why this wouldent work, what is the problem your having?


Have you tried creating your own function?


D_Stark im only passing 4/5 cases lol


Do you have a link for it so I can see the question ?




I dont have pro sorry maby someone else can help 😊


D_Stark the question: Write a program to take numbers as input and return the first number raised to the power of the second number. Sample Input 2 4 Sample Output 16.0 //The only thing I added to the code was the num3 line and the print line.


double num3 = (double) Math.pow(num1, num2);