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 output buffer?
What is a dynamic array in java?
What is the difference between the synchronized() & static synchronized()?
Objects or references which of them gets garbage collected?
What is string subsequence method?
What are the advantages of encapsulation in java?
Explain the difference between scrollbar and scrollpane?
What is the synonym of string?
primitive data types in Java ?
What is hashset in java?
I want to persist data of objects for later use. What is the best approach to do so?
Difference between ‘is-a’ and ‘has-a’ relationship in java?