65 776
Assignments Done
99,4%
Successfully Done
In October 2018

Answer to Question #9092 in Java | JSP | JSF for tarik

Question #9092
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
Expert's answer
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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions