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 it mean to flush a file?
Can you make a constructor final?
Why is the type for real numbers called double?
What are the 7 types of characters?
What is float in java?
what methods would you overwrite in java.lang.object class?
How can we make copy of a java object?
What is a locale?
What are different types of constants?
What is the full form of jpeg?
Can a abstract class be declared final?
How do I get the | symbol on my keyboard?
What is fail first in java?
What is int argc char * argv?
Distinguish between a predicate and a function?