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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What does opcode mean?

526


What is difference between string and new string?

530


What is use of set in java?

486


What is the difference between a factory and abstract factory pattern?

681


Explain hashset and its features?

572






Is singleton class thread safe?

531


Is string is a keyword in java?

545


Why can we not override static method?

583


What is the difference between integer parseint and integer valueof?

542


How many unicode characters are there?

548


what is aggregation in java?

582


What are the important features of Java 10 release?

508


what is session in java?

737


what do you mean by java annotations?

540


How hashmap works in java?

558