Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 14th, 2004, 4:05 AM   #1
Darren
Newbie
 
Join Date: Sep 2004
Posts: 10
Rep Power: 0 Darren is on a distinguished road
i done this program,but when i execute the program,computer will display
"Exception in thread" main"java.lang.NosuchMethodError:main"
y ah? any 1 can help me??

Below are my coding

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Project extends JApplet implements ActionListener
{
CheckboxGroup p = new CheckboxGroup();
Checkbox NONE = new Checkbox("NONE",p,true);
Checkbox LAN1001 = new Checkbox("LAN1001",p,false);
Checkbox LAN1003 = new Checkbox("LAN1003",p,false);
Checkbox LAN1005 = new Checkbox("LAN1005",p,false);
JTextField name, icno, csc230, csc231, csc239, mgt227, enl205,
result1, result2, result3, result4, lan1;
JButton Calculatebutton;
public void init()
{
Container container= getContentPane();
JLabel data1Label= new JLabel ("BMS SEM1");
JLabel space2Label= new JLabel ("");
JLabel dataLabel= new JLabel (" Please enter your marks to get your grade:");
JLabel spaceLabel = new JLabel ("");
JLabel nameLabel= new JLabel ("Student name");
JLabel icnoLabel = new JLabel ("ICNO");
JLabel space1Label= new JLabel ("");
JLabel csc230Label= new JLabel ("CSC230");
JLabel csc231Label= new JLabel ("CSC231");
JLabel csc239Label= new JLabel ("CSC239");
JLabel mgt227Label= new JLabel ("MGT227");
JLabel enl205Label= new JLabel ("ENL205");
JLabel spaceLabel2= new JLabel (" ");
JLabel info= new JLabel ("if you are not taking please enter 0 in the textbar:");
JLabel spaceLabel1= new JLabel ("");

name= new JTextField (20);
icno= new JTextField (20);
csc230= new JTextField (7);
csc231= new JTextField (7);
csc239= new JTextField (7);
mgt227= new JTextField (7);
enl205= new JTextField (7);
result1= new JTextField (75);
result2= new JTextField (75);
result3= new JTextField (75);
result4= new JTextField (75);
lan1= new JTextField (7);
Calculatebutton= new JButton ("Enter");
container.setLayout (new FlowLayout (FlowLayout.LEFT));
container.add (data1Label);
container.add (space2Label);
container.add (dataLabel);
container.add (spaceLabel);
container.add (nameLabel);
container.add (name);
container.add (icnoLabel);
container.add (icno);
container.add (space1Label);
container.add (csc230Label);
container.add (csc230);
container.add (csc231Label);
container.add (csc231);
container.add (csc239Label);
container.add (csc239);
container.add (mgt227Label);
container.add (mgt227);
container.add (enl205Label);
container.add (enl205);
container.add (spaceLabel2);
container.add (info);
container.add (spaceLabel1);
container.add (NONE);
container.add (LAN1001);
container.add (LAN1003);
container.add (LAN1005);
container.add (lan1);
container.add (result1);
result1.setEditable (false);
container.add (result2);
result2.setEditable (false);
container.add (result3);
result3.setEditable (false);
container.add (result4);
result4.setEditable (false);


Calculatebutton.addActionListener (this);
container.add (Calculatebutton);
}

public void actionPerformed (ActionEvent e)
{
String g1, g2, g3, g4, g5, ag, lann1;
float avg, total;
float a =Integer.parseInt (csc230.getText());
float b =Integer.parseInt (csc231.getText());
float c =Integer.parseInt (csc239.getText());
float d =Integer.parseInt (mgt227.getText());
float x =Integer.parseInt (enl205.getText());
float la1=Integer.parseInt (lan1.getText());
String y = icno.getText();
String z = name.getText();

if(a<=100 && a>70)
g1 = "A";
else if(a<=69 && a>50)
g1 = "B";
else if(a<=50 && a>40)
g1 = "C";
else
g1 = "D";

if(b<=100 && b>70)
g2 = "A";
else if(b<=69 && b>50)
g2 = "B";
else if(b<=50 && b>40)
g2 = "C";
else
g2 = "D";

if(c<=100 && c>70)
g3 = "A";
else if(c<=69 && c>50)
g3 = "B";
else if(c<=50 && c>40)
g3 = "C";
else
g3 = "D";

if(d<=100 && d>70)
g4 = "A";
else if(d<=69 && d>50)
g4 = "B";
else if(d<=50 && d>40)
g4 = "C";
else
g4 = "D";

if(x<=100 && x>70)
g5 = "A";
else if(x<=69 && x>50)
g5 = "B";
else if(x<=50 && x>40)
g5 = "C";
else
g5 = "D";

total = a + b + c + d + x;
avg = total / 5;

if(avg<=100 && avg>70)
ag = "A";
else if(avg<=69 && avg>50)
ag = "B";
else if(avg<=50 && avg>40)
ag = "C";
else
ag = "D";


if(la1<=100 && la1>70)
lann1 = "A";
else if(la1<=69 && la1>50)
lann1 = "B";
else if(la1<=50 && la1>40)
lann1 = "C";
else
lann1 = "D";





Object Source=e.getSource();
if (e.getSource()==Calculatebutton)
{

result1.setText ("Your name is "+z+", your ic number is "+y);
result2.setText (" your CSC230 grade is " +g1+", CSC231 grade is "+g2+", CSC239 grade is "+g3+", MGT227 grade is "+g4+", and ENL205 grade is "+g5);
result3.setText (" your total marks of all subjects is " +total+ " your average mark is " +avg+ " and your average grade is " +ag);
Checkbox cb = p.getSelectedCheckbox();
String mode = cb.getLabel();
if(mode.equals("NONE"))
result4.setText("you don't have taken LAN subject in this semester");
else if(mode.equals("LAN1001"))
result4.setText("you are taking LAN1001 and your grade is "+lann1);
else if(mode.equals("LAN1003"))
result4.setText("you are taking LAN1003 and your grade is "+lann1);
else if(mode.equals("LAN1005"))
result4.setText("you are taking LAN1005 and your grade is "+lann1);
}
}
}
Darren is offline   Reply With Quote
Old Oct 14th, 2004, 4:32 AM   #2
Berto
Programming Guru
 
Join Date: Aug 2004
Posts: 1,022
Rep Power: 6 Berto is on a distinguished road
Send a message via AIM to Berto Send a message via MSN to Berto
You need a main method

public stactic void main (str args[]); <--- soemthing like that cant remember, otherwise the program does not no where to start from.
__________________
"Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. THAT'S relativity."

- Albert Einstein
Berto is offline   Reply With Quote
Old Oct 14th, 2004, 6:47 AM   #3
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
Or try viewing from AppletViewer.
__________________
&quot;Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children.&quot; - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Oct 14th, 2004, 10:08 AM   #4
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Yes. A main function is required.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Oct 15th, 2004, 8:03 PM   #5
BoeMan
Newbie
 
Join Date: Oct 2004
Posts: 5
Rep Power: 0 BoeMan is on a distinguished road
In a program like this that acts as your "main" or primary method. You need a statement that denotes a main method like, "public static void main (String []args)"... good luck

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Project extends JApplet implements ActionListener
{
//INSERT IT HERE
public static void main (String [] args)
//INSERT IT HERE
{
CheckboxGroup p = new CheckboxGroup();
BoeMan is offline   Reply With Quote
Old Oct 17th, 2004, 12:00 PM   #6
Darren
Newbie
 
Join Date: Sep 2004
Posts: 10
Rep Power: 0 Darren is on a distinguished road
still have error leh??
Does anyone have try to copy and execute my coding??
Darren is offline   Reply With Quote
Old Oct 17th, 2004, 12:07 PM   #7
Darren
Newbie
 
Join Date: Sep 2004
Posts: 10
Rep Power: 0 Darren is on a distinguished road
i add

public static void main(String args[])
{
//create instance of Frame
Project myframe = new Project( );
myframe.addWindowListener(
new WindowAdapter( ) {
public void windowClosing(WindowEvent e)
{
System.exit(0);
}//end of windowclosing method
}
);
}



but still canot
Darren is offline   Reply With Quote
Old Oct 17th, 2004, 7:35 PM   #8
BoeMan
Newbie
 
Join Date: Oct 2004
Posts: 5
Rep Power: 0 BoeMan is on a distinguished road
Hmmm, I am a complete java newb and am just taking my first programming class but... are you calling any methods in your programs from other java class programs? If so, make sure that you have them compiled first before trying to compile this beast.

good luck sir
BoeMan is offline   Reply With Quote
Old Oct 18th, 2004, 12:28 AM   #9
Darren
Newbie
 
Join Date: Sep 2004
Posts: 10
Rep Power: 0 Darren is on a distinguished road
no wow,i din call any method
my coding just dun have a main class
so i try to add in
but still cannot
y??
help help
urgent
Darren is offline   Reply With Quote
Old Oct 18th, 2004, 1:31 AM   #10
BoeMan
Newbie
 
Join Date: Oct 2004
Posts: 5
Rep Power: 0 BoeMan is on a distinguished road
what are you using to code in? if you are using an IDE what error message are you recieving? get textpad and compile it in there, then see what error message you get.
I just fought with a java program for 5 hours, it was very frustrating but once it worked it was very rewarding. stay at it, you will get it.

public class Project extends JApplet implements ActionListener

drop the "extends ...." to the second line, then compile

public class Project
xtends JApplet implements ActionListener
then be sure the file name is Project.java

seemed to compile fine for me
good luck
BoeMan is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:14 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC