Help me with the codes please

Discussion in 'Java' started by nairobian_0, Oct 14, 2006.

  1. nairobian_0

    nairobian_0 New Member

    Joined:
    Oct 14, 2006
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    TASK 1
    A} To get a degree from the Nairobi university , a student needs to successfully complete 26 modules.A student needs to take 10 modules in year 1 and 8 modules in two subsequent years.A part-time student needs to take a maximum of 8 modules in year 1 and a maximum of of 6 modules in each of subsequent 3 year.

    Design a java program that a student could use to select their module choices for each year of their study.The program should be able to inform a student of the modules which have been:
    -Successfully passed to date
    -Not selected to date
    -Failed to date
    B} The program developed in part a} is to be exetended to provide the following additional functionality:
    .Each student object is to be written into a binary file.
    .Display a list of students who have failed 2 or more modules in the course of their study.
    .Display a list of students, in alphabetical order, who have completed their degree.

    TASK 2
    An interface has two buttons labelled "Create" and "Exit".Each time a user presses the "Create" button two circles appear at random postions on the screen.The circles need not be of the same size. Once the user presses the "Exit" button,the program is to display the number of times that:
    .The area of the two circles do not Overlap.
    .The areas of the two circles Overlap.
    .The areas of the two circles totally overlap.
    in each case the system is to emit an appropriate audio indicating the nature of the circle overlaps(the 3 diffrent scenarios decribed above).Note that the "Create" button may be pressed a number of times before the "Exit" buttonis pressed which displays the result and ends the program.

    TASK 3
    A user is interested in an alphabetical list of all the 4-letter words which have been used in a text file.To archiev this, a program is required:
    .To read the lines from the text file and transferall the words into a string array whose size should not exceded 10.
    .Another part of the progarmm takes the words, one at a time, from the string array and adds it into an ArrayList,provided it is a 4-letter word.Duplicate words are not allowed.
    .In addition, the program should be able to provide an alpahbetical list of these 4-letter words.
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
  3. nairobian_0

    nairobian_0 New Member

    Joined:
    Oct 14, 2006
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    pliz help finish with task two
    Code:
    
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class OverlappingCircles extends JFrame implements ActionListener
    {
    	JButton btnExit=new JButton("Exit");
    	JButton btnCreate=new JButton("Create");
    	int flag=0;
    
    
    	public OverlappingCircles()
    	{
    		setDefaultCloseOperation(EXIT_ON_CLOSE);
    		setSize(600,600);
    		setTitle("Overlapping Circles");
    		Container con=getContentPane();
    		flag=1;
    		setContentPane(con);
    		con.setLayout(new BorderLayout());
    		btnCreate.addActionListener(this);
    		btnExit.addActionListener(this);
    
    		con.add(btnCreate,"North");
    		con.add(btnExit,"South");
    
    	}
    	public static void main(String[] args)
    	{
    		OverlappingCircles x=new OverlappingCircles();
    		x.setVisible(true);
    	}
    	public void actionPerformed(ActionEvent e)
    	{
    		if (e.getSource()==btnCreate)
    		{
    			repaint();
    		}
    		else if(e.getSource()==btnExit)
    		{
    			flag=2;
    			repaint();
    		}
    	}
    	public void paint(Graphics g)
    	{
    		if (flag==1)
    		{
    			int x1=Math.round((int)(Math.random()*600));
    			int x2=Math.round((int)(Math.random()*600));
    			int y1=Math.round((int)(Math.random()*400));
    			int y2=Math.round((int)(Math.random()*400));
    			g.drawOval(x1,y1,100,100);
    			g.drawOval(x2,y2,100,100);
    			//code to count and produce sound
    		}
    	}
    
    }
     
    Last edited by a moderator: Oct 19, 2006
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Can you please clarify what you are looking for rather than putting the complete assignment of what needs to be done.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice