60 478
Assignments Done
98,1%
Successfully Done
In April 2018

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
Expert's answer
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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions