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
What does opcode mean?
What is difference between string and new string?
What is use of set in java?
What is the difference between a factory and abstract factory pattern?
Explain hashset and its features?
Is singleton class thread safe?
Is string is a keyword in java?
Why can we not override static method?
What is the difference between integer parseint and integer valueof?
How many unicode characters are there?
what is aggregation in java?
What are the important features of Java 10 release?
what is session in java?
what do you mean by java annotations?
How hashmap works in java?