Write a program that takes a 5 digit number and calculates
2 power
that number and prints it.



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

Post New Answer

More Core Java Interview Questions

can we access the super class method using subclass object?

4 Answers  


Why would you desing a J2EE application so user data is entered by way of a JSP page and managed by an underlying Java Beans class?

5 Answers   Adobe,


If try block is successfully executed, Then Is Finally block executed?

0 Answers   PUCIT,


What is the difference between set and list?

5 Answers  


What is the difference between Static and final?

1 Answers  






Does a class inherit the constructor of its super class?if it does, how can you hide that constructor? if it doesnot how can you call it from the sub class?

2 Answers  


What is stringjoiner ?

0 Answers  


When can you say a graph to be a tree?

0 Answers   Amazon,


Which class has no duplicate elements?

8 Answers  


What is a short in java?

0 Answers  


Why is java not 100% pure oops?

0 Answers  


What is the purpose of extern variable?

0 Answers  


Categories