I have just embarked on a Java programming course and have been given a task to work out the volume of a cylinder in cubic inches with a given radius and height. and then to convert it from cubic inches to to cubic Cm's which i have done fine.
My problem is it wont complie with an error on one of the
System.out.print
lines that i have in the program
i have checked that i have the syntax correct and it still wont compile.
Would some one be able to give me some advice
I know this is going to sound like a totaly dumb request but hey we all have to start somewhere dont we

Recommended Answers

All 7 Replies

Post the error that you're getting. Often, a syntax error may not be on the line given by the message. It could be a few lines up and the effect of the error isn't seen by the parser until that line.

Check for missing semi colens ';'

That would be my first attempt at finding the problem.

Could you post the code that you've done till now ... that way we can be more helpful.

I slightly modified your post's topic to make it more polite. " Very New to Java and need help ASAP" implied that you deserve precedence over someone else's post, which is kind of considered poor etiquette. Additionally, your thread title has no relevance to your actual question. Creating a relevant thread title also helps you attract people who could help with your problem.

Just letting you know for future reference.

Hi thanks for replying to my request i have checked and double checked everything and still cant get it to compile. i hope its not too much to ask if you could have a look at this for me.
thanks i advance if you can

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class InputCircle
{

    public static void main(final String [] pArgs) throws IOException

    {

    final InputStreamReader tInputStreamReader = new InputStreamReader(System.in);
    final BufferedReader tKeyboard = new BufferedReader(tInputStreamReader);

            final double tPi = 3.141592653589793;
            double tRadius, tArea, tDiameter, tCircumfrence, tNum1,tLine1 ;
            tRadius = (tLine1);
            tArea = tPi * tRadius * tRadius;
            tDiameter = tRadius + tRadius;
            tCircumfrence = tPi * tDiameter;

    String tFirstLine = tKeyboard.readLine();
    tFirstLine = tFirstLine.trim();
    int tFirstInt = Integer.parseInt(tFirstLine);
    System.out.print("Type in a number That is the Radius of you Circle ");
    System.out.flush();

    final String tLine1 = tKeyboard.readLine();
    final int tNum1 = Integer.parseInt(tLine1);

    final String tLine2 = tKeyboard.readLine();
    final int tNum2 = Integer.parseInt(tLine2);

    System.out.println("The subtraction is" + (tNum1 - tNum2));

Thanks for letting me know the rules and stuff i am Pretty new to forums in fact very new its the first time i have ever used one. I will bear in mind what you have said if i need more help

Thanks for the Advice grifflyn

You have alot of conversion problems that need to be fixed. But even when they are fixed the program doesnt really work the way you have it. If you want to convert the input to a double do something like this:

Double d = Double.valueOf(BufferedReaderVariableName.readLine().trim());
double d2 = d.doubleValue();

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.