Answer to Question #46278 in Java | JSP | JSF for Fel

Question #46278
Java programming.

Find the area of a triangle

Area =1/2base x height
1
Expert's answer
2014-09-12T13:26:51-0400
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Triangle {
public static void main(String[] args) {
BufferedReader buffRead = new BufferedReader(new InputStreamReader(System.in));
double base = 0, height = 0;

System.out.print("Enter base: ");
try {
base = Double.parseDouble(buffRead.readLine());
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

System.out.print("Enter height: ");
try {
height = Double.parseDouble(buffRead.readLine());
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

System.out.println("Area equals " + 0.5*base*height);
}
}

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 the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS