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
Is a class subclass of itself?
What are the advantages of assembly language?
How do I find and replace in word?
Write a program in java to calculate the difference between the sum of the odd level and even level nodes of a binary tree.
What is casting in java programming?
How to find the index of the largest number in an arraylist java?
What is a flag and how does it work?
What is parsing a sentence?
What does escaping a character mean?
What is the difference between state-based unit testing and interaction-based unit testing?
What is prime number in java?
What do you understand by copy constructor in java?
Give the hierarchy of inputstream and outputstream classes.
What are the special characters?
Why is it called boolean?