Write a program that takes a 5 digit number and calculates
2 power
that number and prints it.
Answer / r.dhanunjay
import java .io.*;
public class Digits {
public static void main(String[] args) throws IOException
{
try
{
System.out.println("Enter the number with 5 didgits");
BufferedReader br= new BufferedReader(new
InputStreamReader( System.in));
String str = br.readLine();
int i =Integer.parseInt(str);
int j =String.valueOf(i).length();
if(j==5)
{
double k =Math.pow(i,2);
System.out.println(k);
}
else
{
System.out.println("enter only 5 didgits number");
}
}
catch(IOException e)
{
System.err.println();
}
}
}
| Is This Answer Correct ? | 7 Yes | 0 No |
What is Session reduplication and how its done?
What are types of Java applications?
What is advantage of using threads?
What is int argc char * argv?
Can singleton class be inherited in java?
What is the purpose of a transient variable?
Why null interfaces are used in Java?
What is Collections API?
What is the use of protected in java?
What's a method in programming?
what is the use of finalize()Method please explain with an example
Can we access the non-final local variable, inside the local inner class?