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 the entry point in Java, and how is it written?
What is protected access modifier?
How do you sort an array in java?
What is the exact difference in between Unicast and Multicast object?
Explain heap sort?
How do you make an arraylist empty in java?
Why we need to serialize the object
11 Answers CTS, Geometric Software,
What is meant by data hiding in java?
How do you convert an int to a string in java?
Is a class subclass of itself?
How do you execute a thread in java?
What is collection api?