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

What is the difference between JDK and JVM?

0 Answers  


How to display arraylist values in java?

0 Answers  


What is nextline method in java?

0 Answers  


Hi friends, i am new to java. can you explain how java is secured.

2 Answers  


How HashMap implemented in java? how it internally works when values are added or searched from hashMap?What is the difference betweenthe implementation of hashmap and Linked Hashmap?

3 Answers   IBM,






What does jre stand for?

0 Answers  


How do you detect memory leaks?

0 Answers  


What are the difference between composition and inheritance in java?

0 Answers  


What is instance example?

0 Answers  


What is lossy conversion in java?

0 Answers  


Can we pass a primitive type by reference in java? How

0 Answers  


Which are different kinds of source code?

0 Answers  


Categories