Answer to Question #9092 in Java | JSP | JSF for tarik
2012-05-09T08:33:36-04:00
write a java application to calculate the exponent value of a number using the following specifications:
prompt the user to enter an integer value. Pass the integer value to the main method square,which squares the number and to a method cubes the number. The results must be returned to the main method. The main method must print the results along with a suitable mesage
1
2012-05-11T07:53:27-0400
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Question9092 { /** & * @param args & */ private static int input; public static void input(){ & & BufferedReader bReader = new BufferedReader (new InputStreamReader(System.in)); & try { & System.out.println("Please, enter a number"); & String data = bReader.readLine(); & input = Integer.parseInt(data); & & } catch (IOException e) { & // TODO Auto-generated catch block & e.printStackTrace(); & } } public static double square(){ & return Math.pow(input, 2); } public static double cube(){ & return Math.pow(input, 3); } public static void main(String[] args) { & // TODO Auto-generated method stub & & input(); & System.out.println("Square: "+ square()); & System.out.println("Cube: "+ cube()); } }
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS !
Learn more about our help with Assignments:
Java JSP JSF
Comments
Leave a comment