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 is t in parametric equations?
What are disadvantages of java?
What differences exist between iterator and listiterator?
Which programming language is best in future?
How many JVMs can run on a single machine and what is the meaning of Just-In-Time (JIT) compiler?
What is the difference between an argument and a parameter?
Explain about the dynamic behavior of core java?
What is the this keyword?
What does the @override annotation do?
Can a constructor be made final?
Explain the use of shift operator in java. Can you give some examples?
How do you check if two strings are equal in java?
what is the difference between preemptive scheduling and time slicing? : Java thread
What is static in java?
How do I run java on windows?