import javax.swing.*;
public class Pool
{
    public static void main(String args[])
    {
        int input1;
        int input2;
        int input3;
        int Volume;

        input1=JOptionPane.showInputDialog(null,"Enter the length of the swimming pool:");
        input2=JOptionPane.showInputDialog(null,"Enter the width of the pool:");
        input3=JOptionPane.showInputDialog(null,"Enter the average depth of the pool:");

        Volume=input1*input2*input3;

        System.out.println("The volume for the pool is: "+ Volume);

    }

}

I have no idea what my error is except that it has something to do with the 3 statements requesting for the InputBoxes. The error in the build output shows the arrow between all the .showinputdialog and (null,.

Can anyone help me out? I'm stumped.

Your JOptionPane is returning a String not an int. Capture your JOptionOutput in a String
variable then do input1 = Integer.parseInt(String var)

I can' figure out what you just explained. What does input1 = Integer.parseInt(String var) do and what do you mean by capturing JOptionOutput in a String variable?

your input1 is a type of integer as in numbers, and your input dialog is will only take in String type as in. so the value being taken by the Dialogbox needs to be converted from string type to int type.

the coding to convert is already given by masijade

Oh Ok thats done. But now it when I compile it it registers the the "var" part of the converter as an error where " ')' expected " is the error. What's the problem now? Sorry to be of such bother but I'm just starting out in Java.

Well, my guess is we would need to look at your code to see where the issue is.

import javax.swing.*;
public class Pool
{
    public static void main(String[] args)
    {
        String input1;
        String input2;
        String input3;
        String Volume;


        input1=JOptionPane.showInputDialog(null,"Enter the length of the swimming pool:");
        input2=JOptionPane.showInputDialog(null,"Enter the width of the pool:");
        input3=JOptionPane.showInputDialog(null,"Enter the average depth of the pool:");


        input1 = Integer.parseInt(String [U]v[/U]ar)
        input2 = Integer.parseInt(String var)
        input3 = Integer.parseInt(String var)


        Volume=input1*input2*input3;

        System.out.println("The volume for the pool is: "+ Volume);

}

}

Is as far as I can figure out. The "car is underlined. Thats where the error shows.

i think u forgot the semicolon ";"

See I thought so too, but when I put the ; for all 3 convert statements then I get 3 of the same earlier errors for all 3 statements saying " ')' expected",

also spotted some other mistakes

See my code

import javax.swing.*;
public class Pool
{
public static void main(String[] args)
{
int input1, input2, input3, Volume;
String a, b, c;

a	=	JOptionPane.showInputDialog(null,"Enter the length of the swimming pool:");
b	=	JOptionPane.showInputDialog(null,"Enter the width of the pool:");
c	=	JOptionPane.showInputDialog(null,"Enter the average depth of the pool:");

input1 = Integer.parseInt( a);
input2 = Integer.parseInt( b);
input3 = Integer.parseInt( c);

Volume=input1*input2*input3;
System.out.println("The volume for the pool is: "+ Volume);

}

}

Oh my Lord!.... I feel so foolish. Eh heh...so the String var actually needs a variable in there. Ehh heh.

2;
int input3;
int Volume;

input1=JOptionPane.showInputDialog(null,"Enter the length of the swimming pool:");
input2=JOptionPane.showInputDialog(null,"Enter the width of the pool:");
input3=JOptionPane.showInputDialog(null,"Enter the average depth of the pool:");

Well i came up with a possible solution which was pretty trivial..
i hope this is what you are looking for..

import javax.swing.*;
public class SwingUtility
{
public static void main(String args[])
{
int input1;
int input2;
int input3;
int Volume;

input1=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter the length of the swimming pool:"));
input2=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter the width of the pool:"));
input3=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter the average depth of the pool:"));

Volume=input1*input2*input3;

System.out.println("The volume for the pool is: "+ Volume);
JOptionPane.showInputDialog(null, "The Volume is : " + Volume);
}

}

Just needed to parse the string to int...

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.