+ 7
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(System.in); int num1 = sc.nextInt(); int num2 = sc.nextInt(); double num3 = Math.pow(num1,num2); //your code goes here System.out.print(num3); } }
13 ответов
+ 2
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
https://www.sololearn.com/discuss/2552818/?ref=app
+ 3
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner read = new Scanner(System.in);
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));
}
}
+ 2
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner read = new Scanner(System.in);
int num1 = read.nextInt();
int num2 = read.nextInt();
System.out.println(Math.pow(num1, num2));
}
}
+ 1
Theres no reason why this wouldent work, what is the problem your having?
+ 1
Have you tried creating your own function?
0
D_Stark im only passing 4/5 cases lol
0
Do you have a link for it so I can see the question ?
0
I dont have pro sorry maby someone else can help 😊
0
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.
0
double num3 = (double) Math.pow(num1, num2);
0
import java.util.*;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num1 = sc.nextInt();
int num2 = sc.nextInt();
double num3 = Math.pow(num1,num2);
//your code goes here
System.out.print(num3);
}
}