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

Why we cannot override static method?

0 Answers  


Is there any tag in htm to upload and download files?

0 Answers  


hi am an engineering student and my next plan is for ms in either in us or australia i got my passport but i dont know anything bout visa can u give brief idea 1)How to get prepared for visa and 2)How to apply for top universities and 3)How to pay the fee and so on These all are basic questions plz give me a clear idea

0 Answers  


can we create object for static class in java

14 Answers   IAP Company, IBM, Marlabs, mPortal, TCS,


What is the difference between overriding and overloading in OOPS.

0 Answers   Axtria, ITC Indian Tobacco Company,


What is thread synchronization in java?

0 Answers  


What best practices should you follow while writing multithreaded code in java?

0 Answers  


Explain tree set and its features?

0 Answers  


enlist some features of jdk.

0 Answers  


Difference between Linked list and Queue?

0 Answers   Virtusa,


Can you make a constructor final?

0 Answers  


What is difference between adapter class and listener?

0 Answers  


Categories