Results 1 to 2 of 2
  1. #1
    ADustedEwok is offline Member
    Join Date
    Dec 2011
    Rep Power

    Default Simple Homework applet problems

    The program has a lot of errors I am brand new to this i need to know what is wrong

    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;

    public class grades extends Applet implements ActionListener
    Label name = new Label ("Please enter your name: ");
    TextField n1 = new TextField(10);

    Label sub1 = new Label ("Please enter your first Subject: ");
    TextField n2 = new TextField(10);

    Label g1 = new Label ("Please enter your first Grade: ");
    TextField n3 = new TextField(10);

    Label sub2 = new Label ("Please enter your second Subject: ");
    TextField n4 = new TextField(10);

    Label g2 = new Label ("Please enter your second Grade: ");
    TextField n5 = new TextField(10);

    Label sub3 = new Label ("Please enter your third subject: ");
    TextField n6 = new TextField(10);

    Label g3 = new Label ("Please enter your third Grade: ");
    TextField n7 = new TextField(10);

    Label sub4 = new Label ("Please enter your fourth subject: ");
    TextField n8 = new TextField(10);

    Label g4 = new Label ("Please enter your fourth Grade: ");
    TextField n9 = new TextField(10);

    Label sub5 = new Label ("Please enter your fifth subject: ");
    TextField n10 = new TextField(10);

    Label g5 = new Label ("Please enter your fifth Grade: ");
    TextField n11 = new TextField(10);

    double avg = 0;
    public void init()


    add (g1);
    add (n3);


    add (g2);
    add (n5);


    add (g3);
    add (n7);


    add (g4);
    add (n9);


    add (g5);
    add (n11);

    public void paint (Graphics g)
    g.drawString ("Average: "+ avg, 3, 50);
    public void actionPerformed(ActionEvent e)
    g1 = Double.parseDouble(n3.getText());
    g2 = Double.parseDouble(n5.getText());
    g3 = Double.parseDouble(n7.getText());
    g4 = Double.parseDouble(n9.getText());
    g5 = Double.parseDouble(n11.getText());
    avg = (g1 + g2 + g3 + g4 +g5)/5;

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power

    Default Re: Simple Homework applet problems

    You need to let folks know what errors are happening and where rather than simply dumping your code in the forum. If your code has many compilation errors you're also going about your coding wrong -- you should not add any new code while a compilation error exists until the error has been fixed.

    Most importantly you'll want to read the Java tutorials to see how a program should be written. This is like math where all knowledge is built incrementally on a solid foundation. Without the foundation we won't be able to help you.

    Edit, this is a double post of an already active post in the forum. Please read the forum rules and don't do this. This thread is being locked. Do not do this again.

Similar Threads

  1. Replies: 4
    Last Post: 01-21-2011, 11:43 PM
  2. Two simple array problems.
    By DMiller in forum New To Java
    Replies: 4
    Last Post: 11-06-2009, 12:50 PM
  3. I need simple java applet
    By silvia in forum Java Applets
    Replies: 4
    Last Post: 01-27-2008, 08:50 AM
  4. problems when I try to run an applet
    By boy22 in forum Java Applets
    Replies: 2
    Last Post: 08-11-2007, 04:47 PM
  5. problems with applet
    By paty in forum Java Applets
    Replies: 1
    Last Post: 08-05-2007, 05:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts