Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

please help me!!

Status
Not open for further replies.

twinclw2002

Programmer
Jan 10, 2004
2
GB
i have written this program but it is not compiling. could u please tell me where and what is the error




import javax.swing.JOptionPane;
import javax.swing.*;


public class ViewList {

public static void main(String[] args)
{
String output;
output =" Baked Beans"+ "\t"+"£0.35 per tin"+" \n" +"Cornflakes"+"\t"+"£1.00 per packet"+"\n" +"Sugar"
+"\t"+"£0.50 per packet" +" \n"+ "Tea Bags"+ "\t"+"£1.15 per packet" + "\n" +"Instant Coffee"+"\t"+"£2.50 per jar" +
"\n" +"Bread"+"\t"+"£0.50 per loaf"+ "\n" + "Sausages"+ "\t "+"£1.30 per packet" +"\n "+"Eggs" + "\t" +"£0.75 per half dozen"
+" \n" + "Milk" + "\t" + "£0.65 per carton" + "\n" + "Potatoes" + "\t" + "£1.00 per kg bag";

JOptionPane.showMessageDialog( null, output, "view items");
System.exit(0);
}
}
 
I am as new to java as you are. In the output statement
insert " in front of output and remove " from View.
The final statement should read JOption.showMessageDialog(null,"output, view items");
Tryit.
 
My answer was too fast.

And finally
JOption.....(null,output);
Tryit.
 


Code:
import javax.swing.*;


public class ViewList {

    public static void main(String[] args) 
    {
        String output;
        output =" Baked Beans"+    "\t"+"£0.35 per tin"+" \n" +"Cornflakes"+"\t"+"£1.00 per packet"+"\n" +"Sugar"
        +"\t"+"£0.50 per packet" +" \n"+ "Tea Bags"+ "\t"+"£1.15 per packet" + "\n" +"Instant Coffee"+"\t"+"£2.50 per jar" +
        "\n" +"Bread"+"\t"+"£0.50 per loaf"+ "\n" + "Sausages"+ "\t "+"£1.30 per packet" +"\n "+"Eggs" + "\t" +"£0.75 per half dozen"
        +" \n" + "Milk" + "\t" + "£0.65 per carton" + "\n" + "Potatoes" + "\t" + "£1.00 per kg bag";

        JOptionPane.showMessageDialog( null, "view items");
        System.exit(0);
    }
 }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top