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 are adapter classes?
Why are lists ordered in java?
How do you make an arraylist empty in java?
Is array a class?
take an array with -ve and +ve value both.find out the nearest value of 0(zero).if two values are same like(-2 and +2)then extract +2 is nearest of 0(zero).
How do you make a thread in java?
Give me some null interfaces in java?
What is meant by final class?
What is the use of a conditional inclusion statement in Java ?
What restrictions are placed on method overloading in java programming?
What is the purpose of java?
What is the scope or life time of instance variables?
What is supplier in java?
Why Java is not pure Object Oriented language?
Define the term string pool?