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


Please Help Members By Posting Answers For Below Questions

What method is used to specify a container's layout in java programming?

552


What language is java written?

544


What is the Scope of Static Variable?

744


Why is the singleton pattern considered to be an anti pattern?

484


Explain reverse a linked list recursive java solution?

541






Can we return null in java?

651


Is constructor inherited?

538


Name some OOPS Concepts in Java?

647


If a method is declared as protected, where may the method be accessed?

542


Explain an algorithm to find depth of a binary tree.

562


What is the difference between serializable and externalizable interfaces?

581


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).

1537


What do you mean by byte code?

525


What is difference between next () and nextline () in java?

546


How many types of methods are there in java?

532