Write a program that takes a 5 digit number and calculates
2 power
that number and prints it.
Answer Posted / 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 |
Post New Answer View All Answers
What is package private scope in java?
In multi-threading how can we ensure that a resource isn't used by multiple threads simultaneously?
How many threads does a core java have?
'A class is a template for an object' explain this statement.
What is java basic concept?
Can you call a method on a null object?
Explain the private protected method modifier?
What is an exception? difference between Checked and Unchecked exception in Java
How is tree Mirroring implemented?
How many types of memory areas are allocated by jvm?
Lowest Common ancestor in a Binary Search Tree and Binary Tree.
Can size_t be negative?
What is local variable and instance variable?
Why we used vector class?
What's the base class of all exception classes?