GIDForums  

Go Back   GIDForums > Computer Programming Forums > Java Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 01-May-2008, 04:34
opoyafred opoyafred is offline
New Member
 
Join Date: May 2008
Posts: 2
opoyafred is on a distinguished road
Exclamation

java assignment (urgent)


i was given an assignment in java and i am stuck please send me the code
i am supposed to use GUI , assist a brother , common guys


Question
Write down an interactive Java program to allow the user to input marks of a student and print out the pass slip of the given student. The student must have sat for 8 subjects. On the slip, this information has to be presented thus:MASAKA NATIONAL EXAMINATIONS BOARD
Name of School: BAMUNAMEMORIALSCHOOL
Name of Student: MawendeScholarstica
|| SUBJECT MARK GRADE
English 80A
Mathematics 50C-
Etc
¦ UNTIL THE SUBJECTS ARE 8
RESULT AAVERAGE 84SUMMARY PASS
N.B. The user must be allowed to input his/her own subjects and a mark but the system must generate the grade like this:80 to 100 A70 to 79 B60 to 69 C50 to 59 D40 to 49 E Below 39 F
please help this my final exam i am stuck
  #2  
Old 02-May-2008, 13:23
JustinFox JustinFox is offline
Junior Member
 
Join Date: Mar 2008
Posts: 59
JustinFox will become famous soon enough

Re: java assignment (urgent)


Me, let alone anyone else wants to write this code for you. I will be glad to assist you in writing it, but I'm not just going to give you all the code (unless you pay me 125 dollars an hour ).

so start writing stuff, and I can help you. But I can't help someone that can't help themselve(dont know if that word is right).

Justin Fox
  #3  
Old 02-May-2008, 15:01
opoyafred opoyafred is offline
New Member
 
Join Date: May 2008
Posts: 2
opoyafred is on a distinguished road

Re: java assignment (urgent)


so far this is what i have come up with , you think i could not come up with something , if you to help me help but stop asking for 125 dollars , i am in 3rd
world country which is uganda ......

JAVA Code:
 
import java.awt.*;
 
import javax.swing.*;
 
import javax.swing.JPanel;
 
import java.awt.event.*;
 
    public class student extends Frame implements ActionListener
 
 
 
 
 
 
{
    public TextField tfName,tf1,tf2,tf3,tf4,tf5,tf6,tf7,tf8,tfavg,tfstatus,tm1,tm2,tm3,tm4,tm5,tm6,tm7,tm8,tg1,tg2,
    tg3,tg4,tg5,tg6,tg7,tg8;//creation of text field
 
    public Button calc,reset;//creation of buttons    
 
    public Label lbsch,lbName,lb9,lb10,lb11,lbMarks,lbGrade,lbavg,lbstatus,lbStat;
 
 
 
    public student()//constructor
 
    { //writes this string on the border
        super("MASAKA NATIONAL EXAMINATIONS BOARD");
 
    // layout of system such as buttons and labels 
        setLayout(new FlowLayout());
 
        JPanel up = new JPanel();
 
        up.setLayout(new FlowLayout());
 
 
        JPanel mid = new JPanel();
 
        mid.setLayout(new FlowLayout(FlowLayout.CENTER));
 
 
        JPanel jp = new JPanel();
 
        jp.setLayout(new GridLayout(8,4));
 
 
        JPanel lw = new JPanel();
        lw.setLayout(new GridLayout(1,4));
 
        JPanel bt = new JPanel();
 
        bt.setLayout(new GridLayout(1,0));
 
        lbsch = new Label("*BAMUNA MEMORIAL*");
 
        lbName = new Label("Name ");
 
        lbStat = new Label(" SUBJECTS ");
 
        lbMarks = new Label("      MARKS ");
 
        lbGrade = new Label(" GRADE ");
 
        lbavg = new Label (" Average ");
        lbstatus = new Label(" DIV ");
        tfName = new TextField(" ");
 
 
        tg1 = new TextField(" ");
        tg2 = new TextField(" ");
        tg3 = new TextField(" ");
        tg4 = new TextField(" ");
        tg5 = new TextField(" ");
        tg6 = new TextField(" ");
        tg7 = new TextField(" ");
        tg8 = new TextField(" ");
        tm1 = new TextField(" ");
        tm2 = new TextField(" ");
        tm3 = new TextField(" ");
        tm4 = new TextField(" ");
        tm5 = new TextField(" ");
        tm6 = new TextField(" ");
        tm7 = new TextField(" ");
        tm8 = new TextField(" ");
        tf1 = new TextField(" ");
        tf2 = new TextField(" ");
        tf3 = new TextField(" ");
        tf4 = new TextField(" ");
        tf5 = new TextField(" ");
        tf6 = new TextField(" ");
        tf7 = new TextField(" ");
        tf8 = new TextField(" ");
        tfavg = new TextField(" ");
        tfstatus = new TextField(" ");
 
 
        add(up);
        up.add(lbsch);
        up.add(lbName); up.add(tfName);    
 
        add(mid);
 
     mid.add(lbStat); mid.add(lbMarks); mid.add(lbGrade);
 
        add(jp);
 
         jp.add(tg1); jp.add(tf1); jp.add(tm1);
         jp.add(tg2); jp.add(tf2); jp.add(tm2); 
         jp.add(tg3); jp.add(tf3); jp.add(tm3); 
         jp.add(tg4); jp.add(tf4); jp.add(tm4);
         jp.add(tg5); jp.add(tf5); jp.add(tm5);
         jp.add(tg6); jp.add(tf6); jp.add(tm6);
         jp.add(tg7); jp.add(tf7); jp.add(tm7);
         jp.add(tg8); jp.add(tf8); jp.add(tm8); 
 
        add(lw);
 
        lw.add(lbavg); lw.add(tfavg); lw.add(lbstatus); lw.add(tfstatus);
 
        add(bt);
 
 
        // creates new buttons 
 
 
        calc = new Button(" Grade");
        bt.add(calc);
        calc.addActionListener(this);
 
        reset = new Button(" Clear ");
        bt.add(reset);
        reset.addActionListener(this);        
 
 
        addWindowListener(new WindowAdapter()
        {
        public void windowClosing(WindowEvent we){
        System.exit(0);
         }
        }
        );
 
    }
 
 
    // listens for action such as clicking buttons
 
    public void actionPerformed (ActionEvent e)
    {
 
        Object o = e.getSource();
 
        if ( o == calc) 
        {
            calculateDetails();
        }
 
        if ( o == reset) 
        {
            resetDetails();
        }
 
 
}
 
    public void calculateDetails()//function for calculating details
    {
 
 
        // this code checks if the marks have been entered
 
    if (tf1.equals("") || tf2.equals("")|| tf3.equals("")|| tf4.equals("")|| tf5.equals("")|| tf6.equals("")|| tf7.equals("")|| tf8.equals(""));
    {
        //popup warning dialog box
            JOptionPane.showMessageDialog(null, "Enter all the marks and subjects \n Click OK to continue", "!WARNING!", JOptionPane.ERROR_MESSAGE);
    }
 
        //gets string and converts it to a float
 
        float marks1,marks2,marks3,marks4,marks5,marks6,marks7,marks8;
        marks1 = Float.parseFloat(tf1.getText().trim());
        marks2 = Float.parseFloat(tf2.getText().trim());
        marks3 = Float.parseFloat(tf3.getText().trim());
        marks4 = Float.parseFloat(tf4.getText().trim());
        marks5 = Float.parseFloat(tf5.getText().trim());
        marks6 = Float.parseFloat(tf6.getText().trim());
        marks7 = Float.parseFloat(tf7.getText().trim());
        marks8 = Float.parseFloat(tf8.getText().trim());
 
 
 
 
 
    //this code grades the exam
 
 
        if(marks1>=80)
        {
            tm1.setText("A");    
        }
        if((marks1<79) && (marks1>=70))
        {
            tm1.setText("B");    
        }
        if((marks1<69) && (marks1>=60))
        {
            tm1.setText("C");    
        }
        if((marks1<59) && (marks1>=50))
        {
            tm1.setText("D");    
        }
        if((marks1<49) && (marks1>=40))
        {
            tm1.setText("E");    
        }
        if(marks1<39)
        {
            tm1.setText("F");    
        }
 
 
        //this code grades the exam
 
 
        if(marks2>=80)
        {
            tm2.setText("A");    
        }
        if((marks2<79) && (marks1>=70))
        {
            tm2.setText("B");    
        }
        if((marks2<69) && (marks1>=60))
        {
            tm2.setText("C");    
        }
        if((marks2<59) && (marks1>=50))
        {
            tm2.setText("D");    
        }
        if((marks2<49) && (marks1>=40))
        {
            tm2.setText("E");    
        }
        if(marks2<39)
        {
            tm2.setText("F");        
        }
        //this code grades the exam //
 
 
        if(marks3>=80)
        {
            tm3.setText("A");    
        }
        if((marks3<79) && (marks1>=70))
        {
            tm3.setText("B");    
        }
        if((marks3<69) && (marks1>=60))
        {
            tm3.setText("C");    
        }
        if((marks3<59) && (marks1>=50))
        {
            tm3.setText("D");    
        }
        if((marks3<49) && (marks1>40))
        {
            tm3.setText("E");    
        }
        if(marks3<39)
        {
            tm3.setText("F");        
        }
        //this code grades the exam
 
        if(marks4>=80)
        {
            tm4.setText("A");    
        }
        if((marks4<79) && (marks1>=70))
        {
            tm4.setText("B");    
        }
        if((marks4<69) && (marks1>=60))
        {
            tm4.setText("C");    
        }
        if((marks4<59) && (marks1>=50))
        {
            tm4.setText("D");    
        }
        if((marks4<49) && (marks1>=40))
        {
            tm4.setText("E");    
        }
        if(marks4<39)
        {
            tm4.setText("F");        
        }
        //this code grades the exam
 
        if(marks5>=80)
        {
            tm5.setText("A");    
        }
        if((marks5<79) && (marks1>=70))
        {
            tm5.setText("B");    
        }
        if((marks5<69) && (marks1>=60))
        {
            tm5.setText("C");    
        }
        if((marks5<59) && (marks1>=50))
        {
            tm5.setText("D");    
        }
        if((marks5<49) && (marks1>=40))
        {
            tm5.setText("E");    
        }
        if(marks5<39)
        {
            tm5.setText("F");        
        }
        //this code grades the exam
 
        if(marks6>=80)
        {
            tm6.setText("A");    
        }
        if((marks6<79) && (marks1>=70))
        {
            tm6.setText("B");    
        }
        if((marks6<69) && (marks1>=60))
        {
            tm6.setText("C");    
        }
        if((marks6<59) && (marks1>=50))
        {
            tm6.setText("D");    
        }
        if((marks6<49) && (marks1>=40))
        {
            tm6.setText("E");    
        }
        if(marks6<39)
        {
            tm6.setText("F");        
        }
        //This code grades the exam
 
        if(marks7>=80)
        {
            tm7.setText("A");    
        }
        if((marks7<79) && (marks1>=70))
        {
            tm7.setText("B");    
        }
        if((marks7<69) && (marks1>=60))
        {
            tm7.setText("C");    
        }
        if((marks7<59) && (marks1>=50))
        {
            tm7.setText("D");    
        }
        if((marks7<49) && (marks1>=40))
        {
            tm7.setText("E");    
        }
        if(marks7<39)
        {
            tm7.setText("F");        
        }
        //this code grades the exam
 
        if(marks8>=80)
        {
            tm8.setText("A");    
        }
        if((marks8<79) && (marks1>=70))
        {
            tm8.setText("B");    
        }
        if((marks8<69) && (marks1>=60))
        {
            tm8.setText("C");    
        }
        if((marks8<59) && (marks1>=50))
        {
            tm8.setText("D");    
        }
        if((marks8<49) && (marks1>=40))
        {
            tm8.setText("E");    
        }
        if(marks8<39)
        {
            tm8.setText("F");        
        }
        // end of grading the exam
 
 
        //This code calculates the average 
 
        float avg = (marks1+marks2+marks3+marks4+marks5+marks6+marks7+marks8)/8;
 
        //displays the division 
        tfavg.setText(""+avg);
 
        if(avg >= 80)
        {
            tfstatus.setText("Div 1");
        }
        if((avg < 79) && (avg>=70))
        {
            tfstatus.setText("Div 2");
        }
        if((avg < 69) && (avg>=60))
        {
            tfstatus.setText("Div 3");
        }
        if((avg < 59) && (avg>=50))
        {
            tfstatus.setText("Div 4");
        }
        if((avg < 49))
        {
            tfstatus.setText("Div X");
        }
 
         }
 
    //this function resets the all the fields
    public void resetDetails()
    {
        tfName.setText("");
 
        tf1.setText(" ");
        tf2.setText(" ");
        tf3.setText(" ");
        tf4.setText(" ");
        tf5.setText(" ");
        tf6.setText(" ");
        tf7.setText(" ");
        tf8.setText(" ");
        tm1.setText(" ");
        tm2.setText(" ");
        tm3.setText(" ");
        tm4.setText(" ");
        tm5.setText(" ");
        tm6.setText(" ");
        tm7.setText(" ");
        tm8.setText(" ");
        tg1.setText(" ");
        tg2.setText(" ");
        tg3.setText(" ");
        tg4.setText(" ");
        tg5.setText(" ");
        tg6.setText(" ");
        tg7.setText(" ");
        tg8.setText(" ");
        tfavg.setText("");
        tfstatus.setText("");
        tf1.requestFocus();//takes the pointer to first text field 
    }
 
 
    public static void main(String [] args)//this the main method all execution of code starts
    {
        student window = new student();//creates an object of class student
        window.setSize(450,500);
        window.setVisible(true);
 
    }
}
Last edited by admin II : 02-May-2008 at 19:57. Reason: Please surround your Java code with [java] your code [/java]
  #4  
Old 02-May-2008, 15:48
JustinFox JustinFox is offline
Junior Member
 
Join Date: Mar 2008
Posts: 59
JustinFox will become famous soon enough

Re: java assignment (urgent)


Your first post seemed to imply that you wanted someone to just do all the work for you. Sorry if I took it the wrong way.

The code looks ok, what is it that you need help with now?

Justin
  #5  
Old 02-May-2008, 18:46
TurboPT's Avatar
TurboPT TurboPT is offline
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,140
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: java assignment (urgent)


Quote:
Originally Posted by opoyafred
... you think i could not come up with something , if you to help me help but stop asking for 125 dollars , i am in 3rd
world country which is uganda ......
cool down, opoyafred, Justin was just joking. [that's why the silly smiley was there]

Others have asked for similar assistance, but expected all code to be completely "pre-packaged" and done for them, but since you didn't originally post any code -- how were we to know you had something available? Even I thought you were seeking a "do-it-all-for-me" solution.

Thanks for posting what you have, but with future code in a post, please place it between [java] [/java] tags.

1. This condition: (scroll right, see the comment)
JAVA Code:
if (tf1.equals("") || tf2.equals("") || tf3.equals("") || tf4.equals("") || tf5.equals("") || tf6.equals("") || tf7.equals("") || tf8.equals(""));  // <<-- NO SEMICOLON HERE.
2. Also, inside the calculateDetails() function, you should add a return just after the popup [but inside the if condition] so that the calculation(s) won't try to happen.

3. There is not any NumberFormatException checking for the inputs before the calculations. Even though the text fields are specified to be 'marks', letters and other characters can be entered by the user.

4. ...and in the grade calculations, be careful!, you are mismatching the conditions!
For example: (check the others too)
JAVA Code:
if((marks7<79) && (marks1>=70)) // both should be marks7, right?
{
tm7.setText("B");
}
if((marks7<69) && (marks1>=60))
{
tm7.setText("C");
}
// I would seriously consider creating a function to check ANY mark, and have it return a grade.
// This way, you would only have one block of these conditions that does all the work.
Is there something else?
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
Last edited by TurboPT : 02-May-2008 at 19:43.
 
 

Recent GIDBlogToyota - 2009 May Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Urgent-need help in completing my java assignment trustme10301 Java Forum 2 02-May-2007 05:31
To post messages / click Buttons of a Java Jar App using code Jun0 C Programming Language 1 06-Jan-2007 15:44
To post messages / click Buttons of a Java Jar App using code Jun0 Java Forum 0 06-Jan-2007 12:14
Scalability in Java and C++ agx Miscellaneous Programming Forum 7 04-Feb-2006 16:35
Made program in Java, trying C++ now, file i/o problems technickel C++ Forum 4 19-Feb-2005 01:32

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 14:44.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.