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

Detail discussions on JVM, memory management and garbage collector.

0 Answers   Expedia,


How do you make an arraylist empty in java?

0 Answers  


How to sort numbers in java without array?

0 Answers  


Why java is called not pure object oriented language?

0 Answers  


What is the purpose of a parameter?

0 Answers  






What is the difference between comparison done by equals method and == operator?

0 Answers  


Can a abstract class be declared final?

0 Answers  


How to synchonise HashMap

4 Answers   IBM,


What is object-oriented paradigm?

0 Answers  


How many types of exception can occur in a java program?

0 Answers  


What do you mean by collectors in java 8?

0 Answers  


What are the high-level thread states in java programming?

0 Answers  


Categories