 I think my issue is in line 18. The program runs just fine, but my answer isn't correct when I enter a radius and height. Not sure what I am doing wrong here.

import java.util.Scanner;
import java.text.DecimalFormat;

public class ConeA
{
public static void main (String[] args)
{
double surface;

Scanner scan = new Scanner (System.in);

System.out.print("Enter the height: ");
double height = scan.nextDouble();

DecimalFormat fmt = new DecimalFormat ("0.##");

System.out.println("The surface area of the cone is: " +
fmt.format(surface));
}
}

Answered by NormR1 563 in a post from

Please copy and paste here the input and output from the program and explain what is wrong with the output and show what the output should be.

you don't have the correct equation
or your code is not following the equation that …

Make sure to use parentheses in the equation to follow the right sequence of operations

All 5 Replies

Please copy and paste here the input and output from the program and explain what is wrong with the output and show what the output should be.

you don't have the correct equation
or your code is not following the equation that you have.

Make sure to use parentheses in the equation to follow the right sequence of operations The surface area of a cone is made up of two parts, added together.
1. The surface area of the base = Pi * R^2
2. The Lateral surface area = (Perimiter of Base * Slant Height [NOT Cone Height]) / 2

Perimiter = 2 * PI * R;
Slant Height = root (R^2 * CH^2);

Assembly Required! I fixed it. I was missing Math.sqrt

import java.util.Scanner;
import java.text.DecimalFormat;

public class ConeA
{
public static void main (String[] args)
{
double surface;

Scanner scan = new Scanner (System.in);

System.out.print("Enter the height: ");
double height = scan.nextDouble();