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

33. try { 34. // some code here 35. } catch (NullPointerException e1) { 36. System.out.print(”a”); 37. } catch (RuntimeException e2) { 38. System.out.print(”b”); 39. } finally { 40. System.out.print(”c”); 41. } What is the result if a NullPointerException occurs on line 34? 1 c 2 a 3 ab 4 ac

5 Answers  


What is nested interface?

0 Answers  


What is the full name of java?

0 Answers  


What is meant by event handling?

2 Answers  


Is alive and join method in java?

0 Answers  






What is compareto?

0 Answers  


How do you create a first line indent?

0 Answers  


How to pass arraylist to stored procedure in java?

0 Answers  


Does substring start with 0?

0 Answers  


What is the purpose of using java.lang.class class?

0 Answers  


Why collection is called framework in java?

0 Answers  


What is a subsequence of a string?

0 Answers  


Categories