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 |
Detail discussions on JVM, memory management and garbage collector.
How do you make an arraylist empty in java?
How to sort numbers in java without array?
Why java is called not pure object oriented language?
What is the purpose of a parameter?
What is the difference between comparison done by equals method and == operator?
Can a abstract class be declared final?
How to synchonise HashMap
What is object-oriented paradigm?
How many types of exception can occur in a java program?
What do you mean by collectors in java 8?
What are the high-level thread states in java programming?