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 method is used to specify a container's layout in java programming?
What language is java written?
What is the Scope of Static Variable?
Why is the singleton pattern considered to be an anti pattern?
Explain reverse a linked list recursive java solution?
Can we return null in java?
Is constructor inherited?
Name some OOPS Concepts in Java?
If a method is declared as protected, where may the method be accessed?
Explain an algorithm to find depth of a binary tree.
What is the difference between serializable and externalizable interfaces?
take an array with -ve and +ve value both.find out the nearest value of 0(zero).if two values are same like(-2 and +2)then extract +2 is nearest of 0(zero).
What do you mean by byte code?
What is difference between next () and nextline () in java?
How many types of methods are there in java?