I wanted display the result with two decimal values? (12.50) but it seems to be displaying 0 instead of 12.50.
Code:
import java.io.*;
public class InputOutput {
public static void main(String[] args) {
String base="";
String height="";
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
try {
System.out.print("Input base value = ");
base = input.readLine();
System.out.print("Input height value = ");
height = input.readLine();
} catch(IOException e) {
System.out.print("Error");
}
int area = 1/2*(Integer.parseInt(base)* Integer.parseInt(height));
System.out.println("The Area of the right triangle is "+ area);
}
}
Last edited: