<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>Java Programming Forums - The Java Community</title>
		<link>http://www.javaprogrammingforums.com/</link>
		<description>The Java Programming Forums are a community of Java programmers from all around the World. Join us now to solve all your Java problems!</description>
		<language>en</language>
		<lastBuildDate>Sun, 19 May 2013 14:48:26 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.javaprogrammingforums.com/images/misc/rss.png</url>
			<title>Java Programming Forums - The Java Community</title>
			<link>http://www.javaprogrammingforums.com/</link>
		</image>
		<item>
			<title>Use Image in a java Class</title>
			<link>http://www.javaprogrammingforums.com/whats-wrong-my-code/29533-use-image-java-class.html</link>
			<pubDate>Sun, 19 May 2013 13:18:59 GMT</pubDate>
			<description><![CDATA[hi everyone.............. 
 
I have a problem, need some help. please........................!!! 
 
I am doing a project "online election system"...]]></description>
			<content:encoded><![CDATA[<div>hi everyone..............<br />
<br />
I have a problem, need some help. please........................!!!<br />
<br />
I am doing a project &quot;online election system&quot; client-server base application.<br />
<br />
I have a party registration class in my program. and I have a party registration form in which I want to upload a image(Poll Symbol) for newly register party. but I don't know how to do this.? <br />
Anyone please help its urgent.? please................</div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/whats-wrong-my-code/"><![CDATA[What's Wrong With My Code?]]></category>
			<dc:creator>M.Jabbar</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/whats-wrong-my-code/29533-use-image-java-class.html</guid>
		</item>
		<item>
			<title>is it possible to zoom layout in android</title>
			<link>http://www.javaprogrammingforums.com/android-development/29532-possible-zoom-layout-android.html</link>
			<pubDate>Sun, 19 May 2013 06:13:59 GMT</pubDate>
			<description>hello friends, 
i am developing apps which has layout and i put some controls on it like button,image so is it possible to zoom in out the layout...</description>
			<content:encoded><![CDATA[<div>hello friends,<br />
i am developing apps which has layout and i put some controls on it like button,image so is it possible to zoom in out the layout without changing position of controls</div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/android-development/">Android Development</category>
			<dc:creator>shreyaskrane</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/android-development/29532-possible-zoom-layout-android.html</guid>
		</item>
		<item>
			<title>new at robotic</title>
			<link>http://www.javaprogrammingforums.com/whats-wrong-my-code/29531-new-robotic.html</link>
			<pubDate>Sun, 19 May 2013 05:38:27 GMT</pubDate>
			<description>i want to learn about robotic and i have no idea where to start. problem is that my college dont have any robotic class. so i have to learn every...</description>
			<content:encoded><![CDATA[<div>i want to learn about robotic and i have no idea where to start. problem is that my college dont have any robotic class. so i have to learn every thing on my own. goal is to build and program a robot.<br />
<br />
should i start learning about hardware or software? even with software i guess there are in many different languages. <br />
<br />
would i have to buy hardware parts? or a kit? is it cheap? any idea of good kits? and would i have to buy any software too? any there any good tutorial on youtube? sorry for a lot of question. any advice you give me will be helpful.<br />
<br />
i want to software in java or c just become i already how who to use it. also i dont want to program kids looking robot like legos etc.. i want to program a robot that i can show other people. i am sure some legos robots are not for kids but my family and friends dont understand software or computers so they probably would laugh it me for it.</div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/whats-wrong-my-code/"><![CDATA[What's Wrong With My Code?]]></category>
			<dc:creator>game06</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/whats-wrong-my-code/29531-new-robotic.html</guid>
		</item>
		<item>
			<title>Anyone got any idea to use text field to search the object that already stored in arraylist or file and display it in text area?</title>
			<link>http://www.javaprogrammingforums.com/whats-wrong-my-code/29530-anyone-got-any-idea-use-text-field-search-object-already-stored-arraylist-file-display-text-area.html</link>
			<pubDate>Sat, 18 May 2013 20:36:45 GMT</pubDate>
			<description>Anyone got any idea to use text field to search the object that already stored in arraylist or file and display it in text area?For example,i type...</description>
			<content:encoded><![CDATA[<div>Anyone got any idea to use text field to search the object that already stored in arraylist or file and display it in text area?For example,i type &quot;Hello&quot; or something that already stored by using text field and then display &quot;Hello&quot;.</div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/whats-wrong-my-code/"><![CDATA[What's Wrong With My Code?]]></category>
			<dc:creator>edwardedward</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/whats-wrong-my-code/29530-anyone-got-any-idea-use-text-field-search-object-already-stored-arraylist-file-display-text-area.html</guid>
		</item>
		<item>
			<title>How can I incorporate images when I click a button</title>
			<link>http://www.javaprogrammingforums.com/java-theory-questions/29529-how-can-i-incorporate-images-when-i-click-button.html</link>
			<pubDate>Sat, 18 May 2013 18:16:21 GMT</pubDate>
			<description><![CDATA[// Objective : When the user clicks the help button an image will pop up  
 
<div class="bbcode_container"> 
                 
<div...]]></description>
			<content:encoded><![CDATA[<div>// Objective : When the user clicks the help button an image will pop up <br />
<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.*;import java.io.*;
import javax.swing.*;import javax.imageio.*;
import java.awt.Color;
import java.awt.Graphics;
&nbsp;
public class GridBags extends JFrame{
&nbsp;
&nbsp;
	JPanel thePanel;
&nbsp;
	public GridBags(){
		super();
&nbsp;
&nbsp;
		//general settings
		this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
		this.setSize(1000, 500);
 		this.setResizable(false);
 		this.setTitle(&quot;Biology Review Program&quot;);
 		this.setVisible(true);
 		this.setLayout(new GridBagLayout());
&nbsp;
		initComponents();
&nbsp;
	}
&nbsp;
	public void initComponents(){
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
		//This variable is changed to allow us to place buttons
		//and other components flexibly on the page.
		GridBagConstraints c = new GridBagConstraints();
		c.fill = GridBagConstraints.NONE;
&nbsp;
		JButton lesson = new JButton(&quot;Lessons&quot;);
		c.gridwidth = 1;
		c.gridheight = 1;
		c.gridx = 1;
		c.gridy = 500;
		this.add(lesson, c);
		lesson.addActionListener(new ActionListener() {
&nbsp;
            public void actionPerformed(ActionEvent e){
				System.out.println(&quot;You clicked for Lesson?&quot;);
&nbsp;
            }
        });  
&nbsp;
		//create the myCreature object
		thePanel = new JPanel();
		//set the size and background of the panel
		thePanel.setPreferredSize(new Dimension(700, 500));
		thePanel.setBackground(new java.awt.Color(0, 0, 0));
		//add the panel to the pane
		c.gridwidth = 2;  //six &quot;buttons&quot; wide
		c.gridheight = 1;
		c.gridx = 3;		//left most
		c.gridy = 1;		//top most
		this.add(thePanel, c);
&nbsp;
		JButton quiz = new JButton(&quot;Quiz&quot;);
		c.gridwidth = 1;
		c.gridheight = 1;
		c.gridx = 2;
		c.gridy = 500;
		this.add(quiz, c);
		quiz.addActionListener(new ActionListener() {
&nbsp;
            public void actionPerformed(ActionEvent e){
				System.out.println(&quot;You clicked for Quiz?&quot;);
&nbsp;
            }
        });  
&nbsp;
&nbsp;
		JButton help = new JButton(&quot;Help&quot;);
		c.gridwidth = 1;
		c.gridheight = 1;
		c.gridx = 3;
		c.gridy = 500;
		this.add(help, c);
		help.addActionListener(new ActionListener() {
  &#91;COLOR=&quot;#FF0000&quot;&#93;	Image img=null;
    		try {img=ImageIO.read(new File(&quot;help.jpg&quot;));}
  			catch(IOException e)
      	    {System.out.println(&quot;ok&quot;);System.exit(0);}
    		g.drawImage(img,200,0,this);&#91;/COLOR&#93;
&nbsp;
&nbsp;
                 public void actionPerformed(ActionEvent e){
				System.out.println(&quot;You clicked for Help?&quot;);
&nbsp;
            }
        });  
&nbsp;
&nbsp;
	}
&nbsp;
&nbsp;
&nbsp;
	public static void main(String&#91;&#93; args){
&nbsp;
		GridBags example = new GridBags();
		example.pack();
		example.show();
	}
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
}</pre></div></code><hr />
</div> </div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/java-theory-questions/"><![CDATA[Java Theory & Questions]]></category>
			<dc:creator>SwagKingzMon</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/java-theory-questions/29529-how-can-i-incorporate-images-when-i-click-button.html</guid>
		</item>
		<item>
			<title>How to read in a file?</title>
			<link>http://www.javaprogrammingforums.com/whats-wrong-my-code/29526-how-read-file.html</link>
			<pubDate>Sat, 18 May 2013 11:13:19 GMT</pubDate>
			<description>Hi,  
 
I was just wondering, how do I read a .txt file into my program even though i do not know the name of the file? Thanks :)</description>
			<content:encoded><![CDATA[<div>Hi, <br />
<br />
I was just wondering, how do I read a .txt file into my program even though i do not know the name of the file? Thanks :)</div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/whats-wrong-my-code/"><![CDATA[What's Wrong With My Code?]]></category>
			<dc:creator>dazzle1218</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/whats-wrong-my-code/29526-how-read-file.html</guid>
		</item>
		<item>
			<title>hi..</title>
			<link>http://www.javaprogrammingforums.com/member-introductions/29525-hi.html</link>
			<pubDate>Sat, 18 May 2013 10:38:05 GMT</pubDate>
			<description>hi everybody... im a new member... so please help me out here...</description>
			<content:encoded><![CDATA[<div>hi everybody... im a new member... so please help me out here...</div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/member-introductions/">Member Introductions</category>
			<dc:creator>Fanta Hubert</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/member-introductions/29525-hi.html</guid>
		</item>
		<item>
			<title>Earliest deadline cpu scheduling algorithm</title>
			<link>http://www.javaprogrammingforums.com/algorithms-recursion/29524-earliest-deadline-cpu-scheduling-algorithm.html</link>
			<pubDate>Sat, 18 May 2013 10:34:12 GMT</pubDate>
			<description><![CDATA[I can't figure out how to show the correct diagram for this earliest deadline first algorithm. So far here is my code: 
<div...]]></description>
			<content:encoded><![CDATA[<div>I can't figure out how to show the correct diagram for this earliest deadline first algorithm. So far here is my code:<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">import java.util.*;
&nbsp;
&nbsp;
    class deadlineprototype
    {
&nbsp;
&nbsp;
    public static void main(String args&#91;&#93;)
    {
&nbsp;
&nbsp;
    Scanner sc = new Scanner(System.in);
&nbsp;
&nbsp;
    System.out.println(&quot;enter no. of processes : &quot;);
    int n=sc.nextInt();
    int job&#91;&#93;=new int&#91;n+1&#93;;
    int burst&#91;&#93;=new int&#91;n+1&#93;;
    int newburst&#91;&#93;=new int&#91;n+1&#93;;
    int arrival&#91;&#93;=new int&#91;n+1&#93;;
    int deadline&#91;&#93;=new int&#91;n+1&#93;;
    int wt&#91;&#93;=new int&#91;n+1&#93;;
    int turn&#91;&#93;=new int&#91;n+1&#93;;
    int tot_turn=0;
    int tot_wait=0;
    float avg_turn=0;
    float avg_wait=0;
    int j;
&nbsp;
    for(int m=1;m&lt;=n;m++)
        {
        arrival&#91;m&#93;=m;
        }
    for(int m=1;m&lt;=n;m++)
        {
        job&#91;m&#93;=m;
        }
&nbsp;
    for(int m=1;m&lt;=n;m++)
        {
        System.out.println(&quot;enter arrival time, burst time and deadline of process &quot;+(m)+&quot;(0 for none):&quot;);
        arrival&#91;m&#93;=sc.nextInt();
        burst&#91;m&#93;=sc.nextInt();
        deadline&#91;m&#93;=sc.nextInt();
&nbsp;
    if (deadline&#91;m&#93;==0){
        deadline&#91;m&#93;=1000;
    }
        }
&nbsp;
&nbsp;
&nbsp;
    int temp;
    for(int i=1;i&lt;n;i++)
        {
        for(j=1;j&lt;n;j++)
            {
&nbsp;
                if(deadline&#91;i+1&#93;&lt;deadline&#91;j&#93;)
                {
                temp=deadline&#91;j+1&#93;;
                deadline&#91;j+1&#93;=deadline&#91;j&#93;;
                deadline&#91;j&#93;=temp;
&nbsp;
                temp=job&#91;j+1&#93;;
                job&#91;j+1&#93;=job&#91;j&#93;;
                job&#91;j&#93;=temp;
&nbsp;
                temp=burst&#91;j+1&#93;;
                burst&#91;j+1&#93;=burst&#91;j&#93;;
                burst&#91;j&#93;=temp;
                }
        }
        }
    turn&#91;1&#93;=burst&#91;1&#93;;    
&nbsp;
    for(int i=2;i&lt;=n;i++)
        {
        turn&#91;i&#93;=burst&#91;i&#93;+turn&#91;i-1&#93;;
        wt&#91;i&#93;=turn&#91;i&#93;-burst&#91;i&#93;;
        }
    for(int i=1;i&lt;=n;i++)
        {
        tot_turn+=(wt&#91;i&#93;+burst&#91;i&#93;)-arrival&#91;i&#93;;
        avg_turn=(float)tot_turn/n;
        tot_wait+=wt&#91;i&#93;-arrival&#91;i&#93;;
        avg_wait=(float)tot_wait/n;
        }
    System.out.println(&quot;----------Earliest Deadline Scheduling Diagram----------&quot;);
    for(int m=1;m&lt;=n;m++)
        {
    if(deadline&#91;m&#93;==1000){
            deadline&#91;m&#93;=0;
            }
    if(wt&#91;m&#93;==0){
            System.out.println(&quot;0&quot;+wt&#91;m&#93;+&quot; _____&quot;); 
    }
    else{
    System.out.println(wt&#91;m&#93;+&quot; _____&quot;); 
    }
            System.out.println(&quot;  |     |&quot;);
&nbsp;
            System.out.println(&quot;  |job &quot;+job&#91;m&#93;+&quot;|&quot;);
&nbsp;
            System.out.println(&quot;  |_____|&quot;);
                    try
                 {
                 //newburst&#91;m&#93;=(burst&#91;m&#93;*1000);
                 Thread.sleep(1000);  
                 }catch (InterruptedException ie)
                 {
                 System.out.println(ie.getMessage());
                 }
    }
    System.out.println((wt&#91;wt.length-1&#93;+burst&#91;burst.length-1&#93;));</pre></div></code><hr />
</div> <br />
If I input 2 processes this will be the output:<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">enter no. of processes : 
    2
    enter arrival time, burst time and deadline of process 1(0 for none):
    0 17 0
    enter arrival time, burst time and deadline of process 2(0 for none):
    0 13 10
    ----------Earliest Deadline Scheduling Diagram----------
    00 _____
      |     |
      |job 2|
      |_____|
    13 _____
      |     |
      |job 1|
      |_____|
    30</pre></div></code><hr />
</div> <br />
It shows the correct intended output. But for 3 processes like this then it will output:<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">enter no. of processes : 
    3
    enter arrival time, burst time and deadline of process 1(0 for none):
    0 17 0
    enter arrival time, burst time and deadline of process 2(0 for none):
    0 13 10
    enter arrival time, burst time and deadline of process 3(0 for none):
    25 14 20
    ----------Earliest Deadline Scheduling Diagram----------
    00 _____
      |     |
      |job 2|
      |_____|
    13 _____
      |     |
      |job 3|
      |_____|
    27 _____
      |     |
      |job 1|
      |_____|
    44</pre></div></code><hr />
</div> It shows an incorrect output, that job 1 should come after job 2 and instead of job 3. But then again if I input 5 process it will show correct output again:<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">enter no. of processes : 
    5
    enter arrival time, burst time and deadline of process 1(0 for none):
    0 17 0
    enter arrival time, burst time and deadline of process 2(0 for none):
    0 13 10
    enter arrival time, burst time and deadline of process 3(0 for none):
    25 14 20
    enter arrival time, burst time and deadline of process 4(0 for none):
    25 10 15
    enter arrival time, burst time and deadline of process 5(0 for none):
    30 5 0
    ----------Earliest Deadline Scheduling Diagram----------
    00 _____
      |     |
      |job 2|
      |_____|
    13 _____
      |     |
      |job 1|
      |_____|
    30 _____
      |     |
      |job 4|
      |_____|
    40 _____
      |     |
      |job 3|
      |_____|
    54 _____
      |     |
      |job 5|
      |_____|
    59</pre></div></code><hr />
</div> And now I wonder what codes is causing the program to show incorrect input. Please help with this problem thanks in advance!</div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/algorithms-recursion/"><![CDATA[Algorithms & Recursion]]></category>
			<dc:creator>eraniichan</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/algorithms-recursion/29524-earliest-deadline-cpu-scheduling-algorithm.html</guid>
		</item>
		<item>
			<title>Updating Garphics of the JPanel</title>
			<link>http://www.javaprogrammingforums.com/whats-wrong-my-code/29523-updating-garphics-jpanel.html</link>
			<pubDate>Sat, 18 May 2013 04:03:03 GMT</pubDate>
			<description><![CDATA[<div class="bbcode_container"> 
                 
<div class="bbcode_description" style="height:24px; background-image:...]]></description>
			<content:encoded><![CDATA[<div><div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">package main;
&nbsp;
import java.awt.*;
import java.awt.Graphics;
import java.awt.event.*;
import javax.swing.*;
import java.text.*;
import java.util.*;
&nbsp;
public class Window {
&nbsp;
	static Color Soviet = new Color(176, 23, 31); //Red
	static Color Union = new Color(205, 173, 0); //Yellow
	static JFrame window;
	static JPanel panel;
	static GroupLayout layout;
	static String KGB1 = &quot;Komitet Gosudarstevenno Bezopasnosti&quot;;
	static String KGB2 = &quot;KGB - Instant Messaging&quot;;
	static String KGB3 = &quot;Dedicated to Julia the Russian&quot;;
	static JLabel Title1, Title2, Title3, Title4;
	static Calendar time;
	static boolean loop1 = true;
	static Graphics2D g2D;
&nbsp;
	static public String Time(){
		time = Calendar.getInstance();
		SimpleDateFormat sdf = new SimpleDateFormat(&quot;HH:mm:ss&quot;);
		return sdf.format(time.getTime());
	}
&nbsp;
	static public void Update(){
		panel.revalidate();
&nbsp;
		Title4 = new JLabel(Time());
		Title4.setForeground(Union);
		Title4.setBounds(10, 70, 50, 20);
		panel.add(Title4);
	}
&nbsp;
	static public void Clear(Graphics g){
		g2D = (Graphics2D) g;
		g2D.fillRect(0, 0, 400, 400);
	}
&nbsp;
	public static void main(String s&#91;&#93;){
&nbsp;
		window = new JFrame(&quot;Instant Messaging v1.0&quot;);
		window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		window.setSize(400, 400);
		window.setResizable(false);
		window.setVisible(true);
&nbsp;
		panel = new JPanel();
		panel.setSize(window.getSize());
		panel.setBackground(Soviet);
		panel.setLayout(null);
		window.add(panel);
&nbsp;
		Title1 = new JLabel(KGB1);
		Title1.setForeground(Union);
		Title1.setBounds(75, 10, 250, 20);
		panel.add(Title1);
&nbsp;
		Title2 = new JLabel(KGB2);
		Title2.setForeground(Union);
		Title2.setBounds(125, 30, 200, 20);
		panel.add(Title2);
&nbsp;
		Title3 = new JLabel(KGB3);
		Title3.setForeground(Union);
		Title3.setBounds(110, 50, 200, 20);
		panel.add(Title3);
&nbsp;
		while(loop1){
			Update();
			Clear(g2D);
			panel.repaint();
		}
	}
}</pre></div></code><hr />
</div> <br />
I'm making a small chat program for my friend with encrypting and decrypting messages. Right now I'm just creating the GUI and I will add the TCP later.  I can't figure out how to update the String Time() without the label overlapping the last String. Thanks for the help.</div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/whats-wrong-my-code/"><![CDATA[What's Wrong With My Code?]]></category>
			<dc:creator>Damian3395</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/whats-wrong-my-code/29523-updating-garphics-jpanel.html</guid>
		</item>
		<item>
			<title>Grocery List</title>
			<link>http://www.javaprogrammingforums.com/whats-wrong-my-code/29522-grocery-list.html</link>
			<pubDate>Sat, 18 May 2013 03:43:16 GMT</pubDate>
			<description><![CDATA[I have many errors and issues with this. I am new to java and this code is throwing me way off. This is very important, please help. 
 
 
<div...]]></description>
			<content:encoded><![CDATA[<div>I have many errors and issues with this. I am new to java and this code is throwing me way off. This is very important, please help.<br />
<br />
<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;
&nbsp;
import java.util.*;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
public class Grocery {
  public static void main(String&#91;&#93; args) {
    Scanner console = new Scanner(System.in);
&nbsp;
  }
   private Scanner keybd;
    private ArrayList &lt;&gt; myList; //the &lt;&gt; are getting an error
&nbsp;
  {
&nbsp;
        keybd = new ArrayList(); //this is another error
        myList = new ArrayList(); //this is another error
    }
&nbsp;
    public void startProgram()
    {
        int option = 0;
        System.out.println(&quot;Welcome to the Grocery Program!&quot;);
        System.out.println(&quot;1. Create a new Grocery List&quot;);
        System.out.println(&quot;2. Add sample items to the List&quot;);
        System.out.println(&quot;3. Remove an Item from the List&quot;);
        System.out.println(&quot;4. Print the list&quot;);
        System.out.println(&quot;5. Print the cost of all the Items&quot;);
        System.out.println(&quot;6. End the program&quot;);
        option = keybd.nextInt();
        keybd.nextLine();
&nbsp;
         switch (option) {
&nbsp;
&nbsp;
            case 1:  createList(); //error
            //this is a break it will exit the loop
            break;
            case 2:  setList(); //error
            break;
            case 3:  removeItem(); //errpr
            break;
            case 4:  printList(); //error
            break;
            case 5:  printCost(); //error
            break;
            case 6:  endProgram(); //error
            break;
            default: inCorect(); //error
            startProgram();
            break;
        } 
    }
&nbsp;
      private void createList()
    {
        //this is a stopper the program will continue until it is typed
        String stop = &quot;st0p&quot;;
        String addAnother = &quot;&quot;; 
        String newItem = &quot;&quot;;
        double newPrice = 0.0;
        //first we ask the question that the user will answer
        System.out.print(&quot;please enter an items name: &quot;);
       String newItem = console.next();
        //next we need to check that variable with the stop
        while(!(newItem.equals(stop))){
            //now we ask the next question 
            System.out.print(&quot;please enter an items price: &quot;);
            String newPrice = console.next();
            keybd.nextLine();
            //this will add a blank line
            System.out.println(); 
            //we than have to ask rhe question again 
            System.out.print(&quot;please enter an items name: &quot;);
            String addAnother = console.next();
            if(newItem &amp;&amp; newPrice ){
                System.out.println(&quot;incorect item please try again&quot;);
                createList();
            }else{
                myList.add();
            }
        }
        startProgram();
    }
&nbsp;
  /*  private void setList()
    {
        //this is sample data that we will fill in for testing purposes 
        myList.add();
        myList.add();
        myList.add();
        myList.add(new Grocery();
        myList.add(;
        myList.add();
        myList.add();
        startProgram();
    }
*/
    private void removeItem()
    {
        //this is a for statement you need to have three statements inside  
        for(){
            //i add a number in front of every item for easy access to data
            System.out.print(index + &quot; &quot; );
            myList.get(index).printItem();
        }
        //ask a question
        System.out.println(&quot;which item would you like to remove?&quot;);
         String remove = keybd.nextInt();
        myList.remove();
        startProgram();
    }
    /**
     * this will print the list
     */
    private void printList()
    {
        for(; ;index++){ 
            myList.get();
        }
        startProgram();
    }
    /**
     * print just the price
     */
    private void printCost()
    {
        for(; index &lt; myList.size();){ 
            System.out.println(myList.get());
        }
        startProgram();
    }
    /**
     * this is an incorrect message 
     */
    private void inCorect()
    {
        System.out.println(&quot;the item you are looking for is invalid please try again&quot;);
    }
    /**
     * this is the end message 
     */
    private void endProgram()
    {
        System.out.println(&quot;Thanks for using this program&quot;);
    }
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
    private double price;
    private String name;
&nbsp;
    /**
     * This is the constructor
     */
    public Grocery(String newName, double newPrice)
    { 
        name = newName;
        price = newPrice;
    }
&nbsp;
&nbsp;
    //======================+Accessors+=================================
    /**
     * this method is to return the name of the item
     * 
     * @return name of item 
     */
&nbsp;
    public String getName()
    {
        return name;
    }
&nbsp;
    /**
     * this will return the price
     * 
     * @return price of item 
     */
&nbsp;
    public double getPrice()
    {
        return price;
    }
&nbsp;
    //======================+Mutators+==================================
    /**
     * this will set a new name of an item
     * 
     * @param  newName a caller will set the name
     */
&nbsp;
    public void setName(String newName)
    { 
        name = newName;
    }
&nbsp;
    /**
     * this will set a new price of an item
     * 
     * @param  newPrice a caller will set the price
     */
&nbsp;
    public void setPrice(double newPrice)
    { 
        price = newPrice;
    }
&nbsp;
    /**
     * this will print an item
     */
&nbsp;
    public void printItem()
    {
        System.out.println(&quot;the item is: &quot; + name + &quot; the price is: &quot;+ price);
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
    }}</pre></div></code><hr />
</div> </div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/whats-wrong-my-code/"><![CDATA[What's Wrong With My Code?]]></category>
			<dc:creator>Tigers27</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/whats-wrong-my-code/29522-grocery-list.html</guid>
		</item>
		<item>
			<title>Creating an exception class</title>
			<link>http://www.javaprogrammingforums.com/object-oriented-programming/29521-creating-exception-class.html</link>
			<pubDate>Sat, 18 May 2013 03:36:56 GMT</pubDate>
			<description>I had to make two classes that search a String array for specific words, and a ItemNotFoundException class. I do not think the exception class is...</description>
			<content:encoded><![CDATA[<div>I had to make two classes that search a String array for specific words, and a ItemNotFoundException class. I do not think the exception class is working correctly though. I am not completely sure though because I am unsure of what the final outcome should in fact be.<br />
<br />
Driver:<br />
<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;
&nbsp;
public class HW5Driver {
&nbsp;
	public final static String FILE_AND_PATH = &quot;longwords.txt&quot;;
	/* 
	 * TODO: Be sure to change the FILE_AND_PATH to point to your local 
	 * copy of longwords.txt or a FileNotFoundException will result
	 */	
&nbsp;
&nbsp;
	//Note how we deal with Java's Catch-or-Declare rule here by declaring the exceptions we might throw
	public static void main(String&#91;&#93; args) throws FileNotFoundException {
		Scanner input = new Scanner(new File(FILE_AND_PATH));
		int wordCount = 0;
		ArrayList&lt;String&gt; theWords = new ArrayList&lt;String&gt;();
&nbsp;
		//read in words, count them
		while(input.hasNext())  {
			theWords.add( input.next() );
			wordCount++;
		}
&nbsp;
		//make a standard array from an ArrayList
		String&#91;&#93; wordsToSearch = new String&#91;theWords.size()&#93;;
		theWords.toArray(wordsToSearch);
&nbsp;
&nbsp;
&nbsp;
		//start with the linear searches
		tryLinearSearch(wordsToSearch, &quot;DISCIPLINES&quot;);
		tryLinearSearch(wordsToSearch, &quot;TRANSURANIUM&quot;);
		tryLinearSearch(wordsToSearch, &quot;HEURISTICALLY&quot;);
		tryLinearSearch(wordsToSearch, &quot;FOO&quot;);
&nbsp;
		//and compare these results to the binary searches
		tryBinarySearch(wordsToSearch, &quot;DISCIPLINES&quot;);
		tryBinarySearch(wordsToSearch, &quot;TRANSURANIUM&quot;);
		tryBinarySearch(wordsToSearch, &quot;HEURISTICALLY&quot;);
		tryBinarySearch(wordsToSearch, &quot;FOO&quot;);
&nbsp;
	}
&nbsp;
	/**
	 * Method tryBinarySearch
	 * precondition: wordsToSearch is a nonempty array of Strings, and target is a non-null string to search for 
	 * 				 in our collection of strings
	 * postcondition: Uses a BinarySearch object (which implements this style of search) to try to find the target string
	 */
	private static void tryBinarySearch(String&#91;&#93; wordsToSearch, String target) {
		//Todo: Build a LinearSearch class that inherits from SearchAlgorithm, and put it in the same directory as this class to successfully compile
		SearchAlgorithm bs = new BinarySearch();
&nbsp;
		try {
			System.out.print( target + &quot; found at index: &quot; + bs.search(wordsToSearch,target));
			System.out.println( &quot; taking &quot; + bs.getCount() + &quot; comparisons.&quot;);
		} 
		catch( ItemNotFoundException e ) {
			System.out.println( target + &quot;:&quot; + e.getMessage());
		}	
	}
&nbsp;
	/**
	 * Method tryLinearSearch
	 * precondition: wordsToSearch is a nonempty array of Strings, and target is a non-null string to search for 
	 * 				 in our collection of strings
	 * postcondition: Uses a LinearSearch object to try to find the target string
	 */
	private static void tryLinearSearch(String&#91;&#93; wordsToSearch, String target) {
		//Todo: Build a LinearSearch class that inherits from SearchAlgorithm, and put it in the same directory as this class to successfully compile
		SearchAlgorithm bs = new LinearSearch();
&nbsp;
		try {
			System.out.print( target + &quot; found at index: &quot; + bs.search(wordsToSearch,target));
			System.out.println( &quot; taking &quot; + bs.getCount() + &quot; comparisons.&quot;);
&nbsp;
		} 
		catch( ItemNotFoundException e ) {
			System.out.println( target + &quot;:&quot; + e.getMessage());
		}	
	}
&nbsp;
}</pre></div></code><hr />
</div> <br />
<br />
ItemNotFoundException class:<br />
<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">public class ItemNotFoundException extends Exception{
&nbsp;
    public ItemNotFoundException(){
        super(&quot;Word not found.&quot;);
    }
&nbsp;
    public ItemNotFoundException(String message){
        super(message);
    }
&nbsp;
}</pre></div></code><hr />
</div> <font color="Silver"><br />
<br />
--- Update ---<br />
<br />
</font>LinearSearch class: <br />
<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">public class LinearSearch extends SearchAlgorithm{
&nbsp;
    public int search(String&#91;&#93; words, String wordToFind){
&nbsp;
        for(int i = 0; i &lt; words.length ; i++){ 
            if(words&#91;i&#93;.equals(wordToFind)){
                break;
            }else{
                incrementCount();
            }
        }
        return getCount();
&nbsp;
    }
}</pre></div></code><hr />
</div> <br />
SearchAlgorithm class: <br />
<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">public abstract class SearchAlgorithm {
&nbsp;
	/**
	 * Method search: a &quot;to-be-defined&quot; method used to implement a specific search strategy over the given array looking for the target word
	 * Precondition: words is a nonempty array and target is a non-null string
	 * Postcondition: if the target word is found, return its index.  
	 *                If not found, throw an ItemNotFoundException (a subclass which you have to make)
	 * 
	 */
	public abstract int search(String&#91;&#93; words, String wordToFind) throws ItemNotFoundException;
&nbsp;
	/**
	 * Utility Features: This class can be used to track the number of search comparisons
	 *                   for use in comparing two different search algorithms
	 */
	private int count = 0;
	public void incrementCount() {
		count++;
	}
	public int getCount() {
		return count;
	}
	public void resetCount() {
		count = 0;
	}
}</pre></div></code><hr />
</div> </div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/object-oriented-programming/">Object Oriented Programming</category>
			<dc:creator>Kristenw17</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/object-oriented-programming/29521-creating-exception-class.html</guid>
		</item>
		<item>
			<title>Virtual Cursor?</title>
			<link>http://www.javaprogrammingforums.com/java-theory-questions/29520-virtual-cursor.html</link>
			<pubDate>Sat, 18 May 2013 02:39:16 GMT</pubDate>
			<description>Imagine this: You make a simple game using a contained within a JFrame. The game is played by moving your mouse around and clicking on different...</description>
			<content:encoded><![CDATA[<div>Imagine this: You make a simple game using a contained within a JFrame. The game is played by moving your mouse around and clicking on different things.<br />
<br />
Can you then make a virtual mouse to interact with that game that will not interfere with your normal cursor actions, and only do things within the JFrame. Like you could browse the web while it is running and it wouldn't interfere.<br />
<br />
Note: This has nothing to do with interacting with the game objects in code directly, but simple a virtual mouse overlay to interact with it in a simulated way.<font color="Silver"><br />
<br />
--- Update ---<br />
<br />
</font>This was also mention in a similar thread here: <a href="!14788!http://www.javaprogrammingforums.com/java-theory-questions/14788-need-alternative-java-awt-robot.html" target="_blank">http://www.javaprogrammingforums.com...awt-robot.html</a></div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/java-theory-questions/"><![CDATA[Java Theory & Questions]]></category>
			<dc:creator>cgskook</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/java-theory-questions/29520-virtual-cursor.html</guid>
		</item>
		<item>
			<title>help with class calling</title>
			<link>http://www.javaprogrammingforums.com/whats-wrong-my-code/29519-help-class-calling.html</link>
			<pubDate>Sat, 18 May 2013 01:17:32 GMT</pubDate>
			<description>Karl Gauss had an algorithm that was more efficient than a for loop for summing the numbers 1 through N. To sum the numbers he used N ( N + 1 ) / 2 
...</description>
			<content:encoded><![CDATA[<div>Karl Gauss had an algorithm that was more efficient than a for loop for summing the numbers 1 through N. To sum the numbers he used N ( N + 1 ) / 2<br />
<br />
Write a program with two java Methods: one to calculate the sum with a for loop and the other using Gauss’s formula. Make calls to the two methods from the main Method.</div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/whats-wrong-my-code/"><![CDATA[What's Wrong With My Code?]]></category>
			<dc:creator>edderz87</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/whats-wrong-my-code/29519-help-class-calling.html</guid>
		</item>
		<item>
			<title>homeework :(</title>
			<link>http://www.javaprogrammingforums.com/whats-wrong-my-code/29518-homeework.html</link>
			<pubDate>Sat, 18 May 2013 01:16:48 GMT</pubDate>
			<description>Karl Gauss had an algorithm that was more efficient than a for loop for summing the numbers 1 through N. To sum the numbers he used N ( N + 1 ) / 2 
...</description>
			<content:encoded><![CDATA[<div>Karl Gauss had an algorithm that was more efficient than a for loop for summing the numbers 1 through N. To sum the numbers he used N ( N + 1 ) / 2<br />
<br />
Write a program with two java Methods: one to calculate the sum with a for loop and the other using Gauss’s formula. Make calls to the two methods from the main Method.</div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/whats-wrong-my-code/"><![CDATA[What's Wrong With My Code?]]></category>
			<dc:creator>edderz87</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/whats-wrong-my-code/29518-homeework.html</guid>
		</item>
		<item>
			<title>Calculating Pi to more digits?</title>
			<link>http://www.javaprogrammingforums.com/java-theory-questions/29517-calculating-pi-more-digits.html</link>
			<pubDate>Fri, 17 May 2013 22:35:35 GMT</pubDate>
			<description>Hey guys! So I have been messing around with calculating pi and I have gotten to the point where I have a loop running from 0 to long.max value. I am...</description>
			<content:encoded><![CDATA[<div>Hey guys! So I have been messing around with calculating pi and I have gotten to the point where I have a loop running from 0 to long.max value. I am using the fallowing infinite series:<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">pi = 4/1 + 4/3 - 4/5 + 4/7 ...</pre></div></code><hr />
</div> I am wondering a few things. First of all, I tried using BigDecimal and BigInteger to do this and it didn't really work out... :( I am wondering, how do I convert this:<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">double pi = 0.0;
				long divisor = 1;
				boolean positive = false;
&nbsp;
				for(long i = 0; i &lt; Long.MAX_VALUE; i++)
				{
					double n = ((double)4 / (double)divisor);
					if(positive)
						pi -= n;
					else
						pi += n;
					positive = !positive;
					divisor += 2;
				}
&nbsp;
				print(&quot;Pi calculated as: &quot; + pi);</pre></div></code><hr />
</div> To use BigInteger/Decimal? Also, are there any more accurate infinite series' that are more accurate AND are just as easy or almost as easy to implement?</div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/java-theory-questions/"><![CDATA[Java Theory & Questions]]></category>
			<dc:creator>sci4me</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/java-theory-questions/29517-calculating-pi-more-digits.html</guid>
		</item>
	</channel>
</rss>
