Welcome to Dream.In.Code
Become a Java Expert!

Join 149,505 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,333 people online right now. Registration is fast and FREE... Join Now!




Help with writng dinner menu

 
Reply to this topicStart new topic

Help with writng dinner menu

snugglesmocha
11 Aug, 2007 - 07:43 AM
Post #1

New D.I.C Head
*

Joined: 14 Apr, 2007
Posts: 28


My Contributions
Hi!! I am writing a dinner menu. My menu will have 3 soups, 3 entrees, 3 desserts. One one item from each group is to be shown. The item prices won't be visible to the user. When the user makes the first choice the running total at the bottom of applet will show the price of the item--and the totalt is reflected as each new item is reflected. I started the code but am not really sure what I'm doing. Can anyone help??? I only did the soups thus far.

CODE
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class TheMenuProgram extends Applet implements ItemListener
{
    String dinnerMenu =
        new String("Dinner Menu");
        Font bigFont = new Font("Arial", Font.BOLD,16);
        Checkbox clamChowderBox = new Checkbox("Clam Chowder");
        Checkbox vegetableSoupBox = new Checkbox("Vegetable Soup");
        Checkbox pepperedchickenBrothBox = new Checkbox("Peppered Chicken Broth");
        double clamChowerPrice = 2.79,
             vegetableSoupPrice = 2.99,
             pepperedchickenBrothPrice = 2.49;
             CheckboxGroup dinnerGrp = new CheckboxGroup();
             Checkbox clamChowderBox = new Checkbox("clamChowder", false, dinnerGrp);
             Checkbox vegetableSoupBox = new Checkbox("vegetableSoup", false, dinnerGrp);
             Checkbox pepperedcickenBrothBox = new Checkbox("pepperedChickenBroth", false, dinnerGrp);
    public void init()
    {
        add(clamChowderBox);
        clamChowderBox.addItemListener(this);
        add(vegetableSoupBox);    
        vegetableSoupBox.addItemListener(this);
        add(pepperedchickenBrothBox);
        pepperedchickenBrothBox.addItemListener(this);
    }    
    public void paint(Graphics gr)
    {
        gr.setFont(bigFont);
        gr.setColor(Color.magenta);    
        gr.drawString("Soup---------", 10,150);
    }
    public void itemStateChanged(ItemEvent Check)
    {
        Dinner Price = 200;
        if(clamChowderBox.getState());    
    {
        Dinner Price += clamChowderPrice;
        Checkbox dinnerSelection = dinnerGrp.getselectedCheckbos();
        if(dinnerSelection == clamChowderBox)
        totalPrice += clamChowder;
        else if(dinnerSelection == vegetableSoupBox);
        totalPrice +=vegetableSoup);
        else pepperedchickenBrothBox.setState(true);
        }
    }

User is offlineProfile CardPM
+Quote Post

skyhawk133
RE: Help With Writng Dinner Menu
11 Aug, 2007 - 07:45 AM
Post #2

Head DIC Head
Group Icon

Joined: 17 Mar, 2001
Posts: 15,262



Thanked: 61 times
Dream Kudos: 1650
Expert In: Web Development

My Contributions
snugglesmocha. You've been here for 4 months now, and every time we ask you to put [code] tags around your code (just like in the example). PLEASE put [code] tags around your code. PLEASE!!!
User is online!Profile CardPM
+Quote Post

Martyr2
RE: Help With Writng Dinner Menu
11 Aug, 2007 - 08:50 AM
Post #3

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,655



Thanked: 313 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
What is really peeving me off about this is that you haven't even attempted to debug this. You know how I know? You have tons of spelling mistakes, you have tons of errors in syntax, you even redefine your checkboxes. I don't consider this even an effort. Try getting something that is very close to compiling and we can help further.

For all I know you copied and pasted this from a website and asking us to write it so that it will work. Please, show some effort and debug this... then we can help you with the logic of choosing meal plans.

P.S. What is with the Dinner class? Provide that code as well if you can.

Thanks.

This post has been edited by Martyr2: 11 Aug, 2007 - 08:51 AM
User is offlineProfile CardPM
+Quote Post

snugglesmocha
RE: Help With Writng Dinner Menu
11 Aug, 2007 - 10:47 AM
Post #4

New D.I.C Head
*

Joined: 14 Apr, 2007
Posts: 28


My Contributions
First, I just keep forgetting the code tags. I copy and paste what I have from my JGrasp and forget about those things. Second, I did write this and did compile the code. It only had two mistakes according to the compiling. I knew about the misspellings and some syntax errors but was looking for someone to look at the code and see where I'm going wrong. This was very rough and I knew that. I worked very hard on what I have so far but not sure if I'm headed in the right direction or not. Any one able to do this?? See posting for dinner menu from snugglesmocha if anyone can help---
User is offlineProfile CardPM
+Quote Post

PennyBoki
RE: Help With Writng Dinner Menu
11 Aug, 2007 - 10:55 AM
Post #5

system("revolution");
Group Icon

Joined: 11 Dec, 2006
Posts: 2,010



Thanked: 7 times
Dream Kudos: 500
Expert In: Java,C++,C

My Contributions
It's true that you had only couple of errors at first, but after fixing them there were a lot more to come. And believe me there are many in this community that are able to do that little applet, the thing is that you just going to have to try harder, because the mistakes were a lot, and they were so trivial, which implies that you have to get back to the basics, like there shouldn't be any semicolon after the if condition, and so on and so forth.
So try to work around that code a little and then post again.

This post has been edited by PennyBoki: 11 Aug, 2007 - 11:44 AM
User is offlineProfile CardPM
+Quote Post

NickDMax
RE: Help With Writng Dinner Menu
11 Aug, 2007 - 11:18 AM
Post #6

2B||!2B
Group Icon

Joined: 18 Feb, 2007
Posts: 2,867



Thanked: 53 times
Dream Kudos: 550
My Contributions
I merged these two topics...

As for the code. Penny is probably right. You need to restructure your code in a clean manner. This will get ride of most of your syntax/structural errors and let you concentrate on logic.

When you write and IF statement use the following format:
CODE
if(condition)
{
    block of code
} else
{
    the else block
}
Note that I didn't use a semi-colon at the end of the if or else lines.

Use indentation to your advantage. You can make you code much clearer. Your code above is a bit confusing because its indentation (which may just be a result of copy/paste).

Use comments. This really helps! First of all it will help you think over the logic of your code as you go. Secondly, when you post your code it helps us understand what you are trying to do, so maybe we can comment more on logic and less on syntax.

I know programming can be frustrating. Computers REQUIRE you to do things correctly. Your code will not function with syntax error, and you posts will not be properly formated unless you use the proper tags.

take a breath, get something to drink and come back to it.

BTW -- you can always edit your post if you find that it didn't format they way you wanted it to... even I have messed up the [code] tags from time to time and had to edit the post to get it right.
User is offlineProfile CardPM
+Quote Post

snugglesmocha
RE: Help With Writng Dinner Menu
18 Aug, 2007 - 11:35 AM
Post #7

New D.I.C Head
*

Joined: 14 Apr, 2007
Posts: 28


My Contributions
Thanks for the additional comments. I have been away for a while and thus from the code too. I'll work on working it again.
smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 06:55PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month