76 800
Assignments Done
Successfully Done
In June 2019

Answer to Question #8510 in Java | JSP | JSF for Fulbert

Question #8510
write a java application to calculate the exponent value of a number using the following specifications:
.prompt the user to enter an interger value
.pass the interger value to the method square, which squares the number and to a method cubes the number. The result must be returned to the main method.
The main method must print the results along with a suitable message
Expert's answer
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.ParseException;
public class Problem {
private int value;
* @param args
public void inputData() throws NumberFormatException{
BufferedReader bReader = new BufferedReader (new InputStreamReader(System.in));
try {
System.out.println("Input data value: ");
String data = bReader.readLine();
value = Integer.parseInt(data);
} catch (IOException e) {
// TODO Auto-generated catch block
public double getSquare(){
return Math.pow(value, 2);
public double getCube(){
return Math.pow(value, 3);
public static void main(String[] args) {
// TODO Auto-generated method stub
Problem p = new Problem();
catch (NumberFormatException e) {
System.out.println("Parse exception!");
System.out.println("Square: "+p.getSquare());
System.out.println("Cube: "+p.getCube());

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!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions