<?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><![CDATA[Java Programming Forums - The Java Community - What's Wrong With My Code?]]></title>
		<link>http://www.javaprogrammingforums.com/</link>
		<description>PLEASE MAKE AN EFFORT TO POST IN THE CORRECT FORUM BELOW FIRST!</description>
		<language>en</language>
		<lastBuildDate>Sun, 26 May 2013 00:30:25 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.javaprogrammingforums.com/images/misc/rss.png</url>
			<title><![CDATA[Java Programming Forums - The Java Community - What's Wrong With My Code?]]></title>
			<link>http://www.javaprogrammingforums.com/</link>
		</image>
		<item>
			<title>Multiple Java Programs That I need Help with</title>
			<link>http://www.javaprogrammingforums.com/whats-wrong-my-code/29655-multiple-java-programs-i-need-help.html</link>
			<pubDate>Sat, 25 May 2013 06:23:57 GMT</pubDate>
			<description><![CDATA[Question 1: 
 
What is the output of the following code? 
<div class="bbcode_container"> 
                 
<div class="bbcode_description"...]]></description>
			<content:encoded><![CDATA[<div>Question 1:<br />
<br />
What is the output of the following 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;">public class Question02b{
       public static void main(String&#91;&#93; args){ SuperClass superA = new
           SuperClass(); SuperClass superB = new SubClass(); SubClass
           sub = new SubClass(); System.out.println(superA.method());
           System.out.println(superB.method());
           System.out.println(sub.method());
           System.out.println(superB.method(1));
           System.out.println(superB.method(1.4));
}}
   class SuperClass { public static String method(){
           return &quot;SuperClass&quot;; } public String method(double a){
    return &quot;SuperClass&quot;; } }
   class SubClass extends SuperClass{ public static String method(){
           return &quot;SubClass&quot;;
}
public String method(int a){
    return
&quot;SubClass&quot;; } }
Question 3 is on page 4</pre></div></code><hr />
</div> <br />
<br />
Question 2:<br />
What are the possible types of objects at runtime that <i>veg</i> in the method <i>omnivore</i> may be pointing<br />
to? And what would the output be?<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 Question03 { void omnivore(Vegetable veg){ veg.eat(); } }
    abstract class Vegetable { protected int roots = 7; public void eat(){
        slice(); saute(); } public static void saute(){
        System.out.println(&quot;Sizzle!&quot;); } public abstract void slice();
}
    class Tuber extends Vegetable { Tuber(){ mash(); } public void slice(){
        System.out.println(&quot;Chop!&quot;); mash();} public void mash(){
        System.out.println(&quot;Glop! &quot; + roots); }
}
    class Potato extends Tuber
        { Potato(){ roots = 59; }
        public void eat(){
if(this.equals(new Potato())) System.out.println(&quot;Spud!&quot;); else
    System.out.println(&quot;Spudless!&quot;);
            super.eat(); } public static void saute(){
        System.out.println(&quot;Crisps!&quot;); } public void mash(){
        System.out.println(&quot;Creamy! &quot; + roots); }
}</pre></div></code><hr />
</div> <br />
Question 3:<br />
There are two errors in this class, what are they and how can they be fixed?<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 Question04c extends OtherClass{
protected int answer(int i) throws DumbQuestionException { if(i &lt; 0){ throw
    new DumbQuestionException(); } else return 6; } }
class OtherClass{ public int answer(int i){ return i; } }
    class DumbQuestionException extends Exception{ }</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>frenchsasha</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/whats-wrong-my-code/29655-multiple-java-programs-i-need-help.html</guid>
		</item>
		<item>
			<title><![CDATA[Please help with my new memory board game excercise, been trying for 1 whole week and still can't finish this..:(]]></title>
			<link>http://www.javaprogrammingforums.com/whats-wrong-my-code/29653-please-help-my-new-memory-board-game-excercise-been-trying-1-whole-week-still-cant-finish.html</link>
			<pubDate>Sat, 25 May 2013 04:47:05 GMT</pubDate>
			<description>Create an application with following requirements:  
Input the length and width of board game manually. 
Width must be an even number, and the max...</description>
			<content:encoded><![CDATA[<div>Create an application with following requirements: <br />
Input the length and width of board game manually.<br />
Width must be an even number, and the max width must be equal to 40/length. For example: length input is 10, thus the maximum input number for width is 4.<br />
The maximum size for memory board game (length*width) is 40<br />
Program will do randomize symbols inside “Memory Board Game” for each square board. There will be only 2 same symbols for each symbol picture. <br />
User will be ask to guess the location of 2 match symbol inside ‘Memory Board Game’. <br />
User gets only 10 chances to guess all the match symbols. <br />
If user guess correctly, the symbols will be opened. <br />
If user guess wrongly, the chance will be deducted by one.<br />
If user finish the chance before guessing all the match symbol, show a message of “You Lose”.<br />
If user able to guess all the match symbols with available chance, show a message of “You Win”<br />
Show user’s score with following formula: <br />
Score = chance * grade<br />
Grade = opened symbols * 10<br />
By the end of game, prompt user if she/he wants to re-play the game.</div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/whats-wrong-my-code/"><![CDATA[What's Wrong With My Code?]]></category>
			<dc:creator>jnesha1990</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/whats-wrong-my-code/29653-please-help-my-new-memory-board-game-excercise-been-trying-1-whole-week-still-cant-finish.html</guid>
		</item>
		<item>
			<title>hello ,have a good day all , i need some answers of these questions...</title>
			<link>http://www.javaprogrammingforums.com/whats-wrong-my-code/29652-hello-have-good-day-all-i-need-some-answers-these-questions.html</link>
			<pubDate>Sat, 25 May 2013 04:25:27 GMT</pubDate>
			<description>1.  Operator effect definition: 
    oi,j ((a1 , a2 , . . . , a12 )) = (b1 , b2 , . . . , b12 ) 
    k = 1, 2, . . . , 12 
    if (a1 , a2 , . . . ,...</description>
			<content:encoded><![CDATA[<div>1.  Operator effect definition:<br />
    oi,j ((a1 , a2 , . . . , a12 )) = (b1 , b2 , . . . , b12 )<br />
    k = 1, 2, . . . , 12<br />
    if (a1 , a2 , . . . , a12 ) &#8712; dom(oi,j )<br />
    bk =<br />
    ak + j<br />
    ak + 120<br />
    if &#8707;l(al &gt; ak ) &#8744; (ak + ai = 0)<br />
    otherwise<br />
    Exercise 4. Create the Java implementation for the function above as a body of a void function!<br />
    We suppose that a1 , a2 , . . . , a12 are integers, and they are accessible in the function body as a[1], a[2],<br />
    . . ., a[12], and b1 , b2 , . . . , b12 are integers, and they are accessible in the function body as b[1], b[2], . . .,<br />
    b[12].<br />
<br />
    answer : <br />
<br />
2.<br />
<br />
    Set of operators:<br />
    O = {o1,2 , o1,3 , o2,1 , o2,3 , o3,1 , o3,2 }<br />
    Domain of operators:<br />
    dom(oi,j ) = {(a1 , a2 , . . . , a12 ) &#8712; N12 | &#8704;k((k = j) &#8835; (ak + i &gt; aj )) &#8743; &#8707;k&#8707;l(a1 = ak &#8727; al )}<br />
    Exercise 3. Create the Java implementation for the preconditions above as a body of a boolean<br />
    function! We suppose that a1 , a2 , . . . , a12 are integers, and they are accessible in the function body as a[1],<br />
    a[2], . . ., a[12].<br />
<br />
    answer : <br />
<br />
3.<br />
<br />
    Set of goal states:<br />
    G = {(a1 , a2 , . . . , a12 ) &#8712; N12 | &#8704;i&#8707;j((ai + aj &gt; 20) &#8835; (ai &#8727; aj &lt; 200))}<br />
    Exercise 2. Create the Java implementation for the goal condition above as a body of a boolean<br />
    function! We suppose that a1 , a2 , . . . , a12 are integers, and they are accessible in the function body as a[1],<br />
    a[2], . . ., a[12]<br />
<br />
    answer : <br />
<br />
4.<br />
<br />
    &#8704;i(&#8707;j((aj &lt; ai ) &#8744; (aj = 1000)) &#8835; (ai &gt; 0) &#8744; &#8707;j(aj = 50))<br />
    where i &#8712; {1, 2, . . . , 6} and j &#8712; {1, 2, . . . , 6}<br />
    Exercise 1. Create the Java implementation for the formula above as a body of a boolean<br />
    function! We suppose that a1 , a2 , . . . , a6 are integers, and they are accessible in the function body as a[1],<br />
    a[2], . . ., a[6].<br />
<br />
    answer : <br />
<br />
5.<br />
<br />
    1.all i exists j a[i] &gt; a[j] or a[1] = a[4]<br />
<br />
    all i ( exists j ( (a[j] &lt; a[i]) or not (a[j] = 1000) ) implies ( a[i] &gt; 0 or exists j ( a[j] = 50 ) ) )<br />
<br />
    implementation in java : <br />
<br />
------------------------------------------------------------------------------------------------<br />
<br />
<br />
Complete the Java implementation of the Breadth-first search<br />
<br />
Exercise 1.  Initialize the database.<br />
Exercise 2.  Construct the solution as an operator list.<br />
Exercise 3.  Complete the code of the extension.<br />
&#10076;<br />
public interface Problem {<br />
State startState();<br />
Collection&lt;Operator&gt; operators();<br />
}<br />
public interface State {<br />
boolean isGoal();<br />
}<br />
public interface Operator {<br />
boolean isApplicable(State s);<br />
State apply(State s);<br />
&#10076;<br />
}<br />
<br />
public abstract class Solver {<br />
private static class Node {<br />
State state;<br />
Operator creator;<br />
Node parent;<br />
int deep;<br />
public Node(State state, Operator op, Node parent ) {<br />
this.deep = parent == null ? 0 : parent.deep + 1;<br />
this.creator = op;<br />
this.parent = parent;<br />
this.state = state;<br />
}<br />
&#10076;<br />
}<br />
public List&lt;Operator&gt; run(Problem p) {<br />
LinkedList&lt;Node&gt; closedNodes = new LinkedList&lt;Node&gt;();<br />
LinkedList&lt;Node&gt; openNodes = new LinkedList&lt;Node&gt;();<br />
/* Exercise 1: Initialize the database. */<br />
<br />
while ( ! openNodes.isEmpty() ) {<br />
Node node = openNodes.removeFirst();<br />
if ( node.state.isGoal() ) {<br />
LinkedList&lt;Operator&gt; solution = new LinkedList&lt;Operator&gt;();<br />
/* Exercise 2: Construct the solution as an operator list. */<br />
<br />
return solution;<br />
}<br />
closedNodes.add(node);<br />
for ( Operator op : p.operators() ) {<br />
if ( op.isApplicable(node.state) ) {<br />
State newState = op.apply(node.state);<br />
/* Exercise 3: Complete the code of the extension<br />
<br />
* (use the search function below when necessary). */<br />
}<br />
}<br />
}<br />
return null;<br />
}<br />
private static Node search(List&lt;Node&gt; nodeList, State state) {<br />
for ( Node node : nodeList )<br />
if ( state.equals(node.state) )<br />
return node;<br />
return null;<br />
}<br />
}</div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/whats-wrong-my-code/"><![CDATA[What's Wrong With My Code?]]></category>
			<dc:creator>sahin11</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/whats-wrong-my-code/29652-hello-have-good-day-all-i-need-some-answers-these-questions.html</guid>
		</item>
		<item>
			<title>Problems with sockets on simple server and client programs.</title>
			<link>http://www.javaprogrammingforums.com/whats-wrong-my-code/29646-problems-sockets-simple-server-client-programs.html</link>
			<pubDate>Fri, 24 May 2013 21:13:58 GMT</pubDate>
			<description>I set up a simple text message server and client using sockets. When I am have both programs running and connected then close the client without...</description>
			<content:encoded><![CDATA[<div>I set up a simple text message server and client using sockets. When I am have both programs running and connected then close the client without inputting &quot;TERMINATE&quot;  I can't connect another client. This is the error stack I'm getting when I close the client. <br />
<br />
java.net.BindException: Address already in use: JVM_Bind<br />
	at java.net.DualStackPlainSocketImpl.bind0(Native Method)<br />
	at java.net.DualStackPlainSocketImpl.socketBind(Unkno  wn Source)<br />
	at java.net.AbstractPlainSocketImpl.bind(Unknown Source)<br />
	at java.net.PlainSocketImpl.bind(Unknown Source)<br />
	at java.net.ServerSocket.bind(Unknown Source)<br />
	at java.net.ServerSocket.&lt;init&gt;(Unknown Source)<br />
	at java.net.ServerSocket.&lt;init&gt;(Unknown Source)<br />
<br />
<br />
I get this error when I have my server and client programs open. I then close the client window, and this error is when a new ServerSocket is created when the runServer() is called in the closeConnection() method is called. When this happens my connection still has a Socket value. How can I properly handle a client termination so another client can connect. <br />
<br />
Another question dealing with threading. At this point I cannot connect more than one client at a time. I know I need to create a thread that handles connecting clients, so I can have multiple clients communicating with each other. I am not sure how to implement this.<br />
<br />
<br />
Here is my server 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 Server extends JFrame {
&nbsp;
	private JTextField enterField;
	private JTextArea displayArea;
	private ObjectOutputStream output;
	private ObjectInputStream input;
	private ServerSocket server;
	private Socket connection;
	private int counter = 1;
&nbsp;
	public Server() {
		super (&quot;Server&quot;);
		enterField = new JTextField();
		enterField.setEditable(true);
		enterField.addActionListener(new ActionListener() {
&nbsp;
			@Override
			public void actionPerformed(ActionEvent event) {
				sendData(event.getActionCommand());
				enterField.setText(&quot;&quot;);
&nbsp;
			}
		});
&nbsp;
		add(enterField, BorderLayout.NORTH);
		displayArea = new JTextArea();
		add (new JScrollPane(displayArea));
		setSize(300,150);
		setLocation(500,500);
		setVisible(true);
	}
&nbsp;
&nbsp;
&nbsp;
	public void runServer() {
		try {
			server = new ServerSocket(50499, 100);
			if(!server.isClosed()){
			displayMessage(&quot;\n Listening on Port: &quot; + server.getLocalPort() + &quot;\n&quot;);
&nbsp;
			}
			while (true) {
				try {
					waitForCommunication();
					getStreams();
					processConnection();
				} catch (EOFException eofException) {
					displayMessage(&quot;\n Server terminated connection &quot;);
				} finally {
					closeConnection();
					++counter;
				}
			}
		} catch (IOException ioException) {
			ioException.printStackTrace();
		}
	}
&nbsp;
	private void closeConnection() {
		displayMessage(&quot;\nTerminating connection\n&quot;);
		setTextFieldEditable(false);
		try {
			output.close();
			input.close();
			connection.close();
		} catch (IOException ioException) {
			ioException.printStackTrace();
		}
		runServer();
&nbsp;
	}
&nbsp;
	private void displayMessage(final String string) {
		SwingUtilities.invokeLater(new Runnable(){
&nbsp;
			@Override
			public void run() {
				displayArea.append(string);
			}
&nbsp;
		});
&nbsp;
	}
&nbsp;
	private void processConnection() throws IOException {
		String message = &quot;Connection Sucessful&quot;;
		sendData(message);
&nbsp;
		setTextFieldEditable(true);
&nbsp;
		do {
			try {
				message = (String) input.readObject();
				displayMessage(&quot;\n&quot; + message);
			} catch (ClassNotFoundException classNotFoundException) {
				displayMessage(&quot;\nUnknown object type recieved&quot;);
			}
		} while (!message.endsWith(&quot;&gt;&gt;&gt; TERMINATE&quot;));
	}
&nbsp;
	private void setTextFieldEditable(final boolean editable) {
		SwingUtilities.invokeLater(new Runnable(){
&nbsp;
			@Override
			public void run() {
				enterField.setEditable(editable);
&nbsp;
			}
&nbsp;
		});
&nbsp;
	}
&nbsp;
	private void getStreams() throws IOException {
		output = new ObjectOutputStream(connection.getOutputStream());
		output.flush();
&nbsp;
		input = new ObjectInputStream(connection.getInputStream());
&nbsp;
		displayMessage(&quot;\nGOt I/O stream \n&quot;);
&nbsp;
	}
&nbsp;
	private void waitForCommunication() throws IOException {
		displayMessage(&quot;Waiting for cennection \n&quot;);
		connection = (server.accept());
		displayMessage(&quot;Connection&quot; + counter + &quot; received from: &quot;
				+ connection.getInetAddress().getHostName());
	}
&nbsp;
	private void sendData(String message) {
		try {
			output.writeObject(&quot;SERVER&gt;&gt;&gt; &quot; + message);
			output.flush();
			displayMessage(&quot;\nSERVER&gt;&gt;&gt; &quot; + message);
		} catch (IOException ioException){
			displayArea.append(&quot;\nError Writing Object&quot;);
		}
	}
}</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>gongshow20</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/whats-wrong-my-code/29646-problems-sockets-simple-server-client-programs.html</guid>
		</item>
		<item>
			<title><![CDATA[Doing my head in! "for" loops]]></title>
			<link>http://www.javaprogrammingforums.com/whats-wrong-my-code/29645-doing-my-head-loops.html</link>
			<pubDate>Fri, 24 May 2013 19:38:20 GMT</pubDate>
			<description><![CDATA[Hey, i'm stuck on a code. In terms of formatting it is printing out what i need, but the final degree values are displaying all the same. each new...]]></description>
			<content:encoded><![CDATA[<div>Hey, i'm stuck on a code. In terms of formatting it is printing out what i need, but the final degree values are displaying all the same. each new 'carbon value' should create a new value for the surface temperature. my equation is correct, but the code to get it to pick up the right carbon value I just cant figure out....<br />
<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code java:</div>
                <hr /><code class="bbcode_code"><div class="java" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #7F0055; font-weight: bold;">public</span> <span style="color: #7F0055; font-weight: bold;">class</span> StageFour
<span style="color: #000000;">&#123;</span>
      <span style="color: #7F0055; font-weight: bold;">public</span> <span style="color: #7F0055; font-weight: bold;">static</span> <span style="color: #7F0055; font-weight: bold;">void</span> main<span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> args<span style="color: #000000;">&#41;</span>
      <span style="color: #000000;">&#123;</span>
          <span style="color: #3F7F5F; font-style: italic;">//Adding Carbon</span>
          <span style="color: #3F7F5F; font-style: italic;">//Problem Parameters</span>
          <span style="color: #7F0055; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">double</span> SOLAR_CONSTANT <span style="color: #000000;">=</span> <span style="color: #cc66cc;">1367.0</span><span style="color: #000000;">;</span>
          <span style="color: #7F0055; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">double</span> ALBEDO <span style="color: #000000;">=</span> <span style="color: #cc66cc;">0.3</span><span style="color: #000000;">;</span>
          <span style="color: #7F0055; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">double</span> STEFANBOLTZMANN <span style="color: #000000;">=</span> 5.67E<span style="color: #000000;">-</span>8<span style="color: #000000;">;</span>
          <span style="color: #7F0055; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">double</span> ORBITAL_RADIUS <span style="color: #000000;">=</span> <span style="color: #cc66cc;">1.0</span><span style="color: #000000;">;</span>
&nbsp;
          <span style="color: #3F7F5F; font-style: italic;">//Declare Variable</span>
          <span style="color: #000066; font-weight: bold;">double</span> surfaceTemperature<span style="color: #000000;">;</span> 
          <span style="color: #000066; font-weight: bold;">int</span> number<span style="color: #000000;">;</span>        
&nbsp;
          <span style="color: #3F7F5F; font-style: italic;">//Create a decimal format object</span>
          <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adecimalformat+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">DecimalFormat</span></a> df <span style="color: #000000;">=</span> <span style="color: #7F0055; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adecimalformat+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">DecimalFormat</span></a><span style="color: #000000;">&#40;</span><span style="color: #0000ff;">&quot;#0.00&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
&nbsp;
         <span style="color: #3F7F5F; font-style: italic;">//Equation.</span>
          <span style="color: #7F0055; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>number <span style="color: #000000;">=</span> <span style="color: #cc66cc;">280</span><span style="color: #000000;">;</span> number <span style="color: #000000;">&lt;=</span> <span style="color: #cc66cc;">400</span><span style="color: #000000;">;</span> number <span style="color: #000000;">+=</span> <span style="color: #cc66cc;">5</span><span style="color: #000000;">&#41;</span>
          <span style="color: #000000;">&#123;</span>
              surfaceTemperature <span style="color: #000000;">=</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Amath+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Math</span></a>.<span style="color: #000000;">pow</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>SOLAR_CONSTANT<span style="color: #000000;">/</span><span style="color: #cc66cc;">4</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">*</span><span style="color: #000000;">&#40;</span><span style="color: #cc66cc;">1.0</span> <span style="color: #000000;">-</span> ALBEDO<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">/</span><span style="color: #000000;">&#40;</span>STEFANBOLTZMANN<span style="color: #000000;">*</span><span style="color: #000000;">&#40;</span><span style="color: #cc66cc;">1.0</span> <span style="color: #000000;">-</span> <span style="color: #000000;">&#40;</span><span style="color: #cc66cc;">0.65</span> <span style="color: #000000;">+</span> <span style="color: #000000;">&#40;</span><span style="color: #cc66cc;">0.1</span> <span style="color: #000000;">+</span> <span style="color: #cc66cc;">0.06</span><span style="color: #000000;">*</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Amath+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Math</span></a>.<span style="color: #000000;">log</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>number<span style="color: #000000;">&#41;</span><span style="color: #000000;">/</span><span style="color: #cc66cc;">280</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">/</span><span style="color: #cc66cc;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">*</span><span style="color: #000000;">&#40;</span>ORBITAL_RADIUS<span style="color: #000000;">*</span>ORBITAL_RADIUS<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>, <span style="color: #cc66cc;">0.25</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">-</span> <span style="color: #cc66cc;">273.15</span><span style="color: #000000;">;</span>
              <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #000000;">out</span>.<span style="color: #000000;">println</span><span style="color: #000000;">&#40;</span><span style="color: #0000ff;">&quot;For a Carbon Level of &quot;</span> <span style="color: #000000;">+</span> number <span style="color: #000000;">+</span> <span style="color: #0000ff;">&quot; the Earth's Surface Temperature is &quot;</span> <span style="color: #000000;">+</span> <span style="color: #000000;">&#40;</span>df.<span style="color: #000000;">format</span><span style="color: #000000;">&#40;</span>surfaceTemperature<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">+</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\u</span>00b0&quot;</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
          <span style="color: #000000;">&#125;</span>
      <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></code><hr />
</div> <br />
I should be getting lines printed from 280 to 400 with increments of 5, calculating eachof these numbers into my formula to get the appropriate degrees. on paper the equation works.. <br />
<br />
I should get something that spits numbers out like <br />
For a Carbon Level of 280 the Earth's Surface Temperature is 13.49°<br />
For a Carbon Level of 285 the Earth's Surface Temperature is 13.55°<br />
For a Carbon Level of 290 the Earth's Surface Temperature is 13.61°<br />
For a Carbon Level of 295 the Earth's Surface Temperature is 13.67° etc<br />
<br />
but it just spits out all the same degrees values of 13.49 for each carbon level number.<br />
<br />
Is anyway able to point out where I have gone wrong in my coding? I cant find any examples to help me out.. <br />
<br />
Cheers guys :)</div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/whats-wrong-my-code/"><![CDATA[What's Wrong With My Code?]]></category>
			<dc:creator>jess91</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/whats-wrong-my-code/29645-doing-my-head-loops.html</guid>
		</item>
		<item>
			<title>Java Image Displayer</title>
			<link>http://www.javaprogrammingforums.com/whats-wrong-my-code/29641-java-image-displayer.html</link>
			<pubDate>Fri, 24 May 2013 11:13:55 GMT</pubDate>
			<description><![CDATA[I am having trouble with my code it is a java image dis-player and i cannot get it to work andi am completely stuck can somebody helpme 
 
<div...]]></description>
			<content:encoded><![CDATA[<div>I am having trouble with my code it is a java image dis-player and i cannot get it to work andi am completely stuck can somebody helpme<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;">/*
   Copyright 2013 Matthew Kowal 
*/
&nbsp;
package GUI;
&nbsp;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Graphics2D;
&nbsp;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
&nbsp;
&nbsp;
@SuppressWarnings(&quot;serial&quot;)
public class MainAppFrame extends JFrame {
&nbsp;
    private JPanel contentPane;
    File targetFile;
    BufferedImage targetImg;
    public JPanel panel,panel_1;
    private static final int baseSize = 128;
    private static final String basePath =!&#91;enter image description here&#93;&#91;1&#93;
            &quot;C:\\Documents and Settings\\Administrator\\Desktop\\Images&quot;;
&nbsp;
    /**
     * Launch the application.
     */
    public static void main(String&#91;&#93; args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    MainAppFrame frame = new MainAppFrame();
                    frame.setVisible(true);
                    frame.setResizable(false);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
&nbsp;
    /**
     * Create the frame.
     */
    public MainAppFrame() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setBounds(100, 100, 550, 400);
        contentPane = new JPanel();
        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
        setContentPane(contentPane);
        contentPane.setLayout(new BorderLayout(0, 0));
&nbsp;
        panel = new JPanel();
        panel.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));
        contentPane.add(panel, BorderLayout.WEST);
&nbsp;
        JButton btnBrowse = new JButton(&quot;Browse&quot;);
        btnBrowse.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                browseButtonActionPerformed(e);
            }
        });
&nbsp;
        JLabel lblSelectTargetPicture = new JLabel(&quot;Select target picture..&quot;);
&nbsp;
        JButton btnDetect = new JButton(&quot;Detect&quot;);
        btnDetect.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
            }
        });
&nbsp;
        JButton btnAddDigit = new JButton(&quot;Add Digit&quot;);
        btnAddDigit.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
            }
        });
&nbsp;
        JButton button = new JButton(&quot;Recognize&quot;);
        button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
            }
        });
&nbsp;
        panel_1 = new JPanel();
        panel_1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));
&nbsp;
        GroupLayout gl_panel = new GroupLayout(panel);
        gl_panel.setHorizontalGroup(
            gl_panel.createParallelGroup(Alignment.LEADING)
                .addGroup(gl_panel.createSequentialGroup()
                    .addGap(6)
                    .addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
                        .addGroup(gl_panel.createSequentialGroup()
                            .addComponent(lblSelectTargetPicture)
                            .addGap(6)
                            .addComponent(btnBrowse))
                        .addGroup(gl_panel.createSequentialGroup()
                            .addGap(10)
                            .addComponent(btnDetect)
                            .addGap(18)
                            .addComponent(btnAddDigit))))
                .addGroup(gl_panel.createSequentialGroup()
                    .addGap(50)
                    .addComponent(button))
                .addGroup(gl_panel.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(panel_1, GroupLayout.PREFERRED_SIZE, 182, GroupLayout.PREFERRED_SIZE))
        );
        gl_panel.setVerticalGroup(
            gl_panel.createParallelGroup(Alignment.LEADING)
                .addGroup(gl_panel.createSequentialGroup()
                    .addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
                        .addGroup(gl_panel.createSequentialGroup()
                            .addGap(7)
                            .addComponent(lblSelectTargetPicture))
                        .addGroup(gl_panel.createSequentialGroup()
                            .addGap(3)
                            .addComponent(btnBrowse)))
                    .addGap(18)
                    .addComponent(panel_1, GroupLayout.PREFERRED_SIZE, 199, GroupLayout.PREFERRED_SIZE)
                    .addGap(22)
                    .addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
                        .addComponent(btnDetect)
                        .addComponent(btnAddDigit))
                    .addGap(18)
                    .addComponent(button)
                    .addContainerGap())
        );
&nbsp;
        panel.setLayout(gl_panel);
    }
    public BufferedImage rescale(BufferedImage originalImage)
    {
        BufferedImage resizedImage = new BufferedImage(baseSize, baseSize, BufferedImage.TYPE_INT_RGB);
        Graphics2D g = resizedImage.createGraphics();
        g.drawImage(originalImage, 0, 0, baseSize, baseSize, null);
        g.dispose();
        return resizedImage;
    }
    public void setTarget(File reference)
    {
        try {
            targetFile = reference;
            targetImg = rescale(ImageIO.read(reference));
        } catch (IOException ex) {
            Logger.getLogger(MainAppFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
&nbsp;
        panel_1.setLayout(new BorderLayout(0, 0));
        panel_1.add(new JLabel(new ImageIcon(targetImg))); 
        setVisible(true);
    }
    private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {
        JFileChooser fc = new JFileChooser(basePath);
        fc.setFileFilter(new JPEGImageFileFilter());
        int res = fc.showOpenDialog(null);
        // We have an image!
        try {
            if (res == JFileChooser.APPROVE_OPTION) {
                File file = fc.getSelectedFile();
                setTarget(file);
            } // Oops!
            else {
                JOptionPane.showMessageDialog(null,
                        &quot;You must select one image to be the reference.&quot;, &quot;Aborting...&quot;,
                        JOptionPane.WARNING_MESSAGE);
            }
        } catch (Exception iOException) {
        }
&nbsp;
    }
}
&nbsp;
&nbsp;
&nbsp;
&nbsp;
//JPEGImageFileFilter.java
&nbsp;
package GUI;
&nbsp;
import java.io.File;
&nbsp;
import javax.swing.filechooser.FileFilter;
&nbsp;
/*
* This class implements a generic file name filter that allows the listing/selection
* of JPEG files.
*/
public class JPEGImageFileFilter extends FileFilter implements java.io.FileFilter
 {
 public boolean accept(File f)
   {
   if (f.getName().toLowerCase().endsWith(&quot;.jpeg&quot;)) return true;
   if (f.getName().toLowerCase().endsWith(&quot;.jpg&quot;)) return true;
   if(f.isDirectory())return true;
   return false;
  }
 public String getDescription()
   {
   return &quot;JPEG files&quot;;
   }</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>coderxx0</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/whats-wrong-my-code/29641-java-image-displayer.html</guid>
		</item>
		<item>
			<title>Need Help With My Task</title>
			<link>http://www.javaprogrammingforums.com/whats-wrong-my-code/29640-need-help-my-task.html</link>
			<pubDate>Fri, 24 May 2013 07:19:25 GMT</pubDate>
			<description>Hi everybody, 
This is my task.I try to solve this problem but I couldnt understand nothing about print out part. 
 
 
//Write a main method which...</description>
			<content:encoded><![CDATA[<div>Hi everybody,<br />
This is my task.I try to solve this problem but I couldnt understand nothing about print out part.<br />
<br />
<br />
//Write a main method which creates a new property object with id 0, price 550000, area 2100 and availability true. <br />
Print out its area in meters squared and then display the string form of the property object.//<br />
<br />
<br />
This my working.What is wrong in this code ?<br />
public class Property {<br />
private double id;<br />
private double price;<br />
private double area;<br />
private boolean availability;<br />
public void propertyAttributes()<br />
{<br />
System.out.println(&quot;id,price,area,availability&quot;+id  +price+area+availability);<br />
}   <br />
<br />
public Property ()<br />
{<br />
id=0;<br />
price=550000;<br />
area=2100;<br />
availability=true;<br />
}<br />
public static void main(String[]args)<br />
{<br />
Property house=new Property();<br />
house.propertyAttributes();<br />
}<br />
}</div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/whats-wrong-my-code/"><![CDATA[What's Wrong With My Code?]]></category>
			<dc:creator>pumpkins</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/whats-wrong-my-code/29640-need-help-my-task.html</guid>
		</item>
		<item>
			<title><![CDATA[[SOLVED] GUI user input error message]]></title>
			<link>http://www.javaprogrammingforums.com/whats-wrong-my-code/29639-gui-user-input-error-message.html</link>
			<pubDate>Fri, 24 May 2013 06:24:56 GMT</pubDate>
			<description>I need help implementing the below code. It currently is the code for a search bar. User enters in keywords and then it matches it against the...</description>
			<content:encoded><![CDATA[<div>I need help implementing the below code. It currently is the code for a search bar. User enters in keywords and then it matches it against the recipe, returning true if so. It then displays the recipes matching in the interface. However, I want to implement an error message for invalid input. Currently with the below code it just brings up the error regardless, I added a break, but then it removed all the content from the interface. else if(recipe.foundWords(keys)) =! true) //do stuff ? is another option I tried.<br />
 Obviously not the result I'm wanting.<br />
<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code java:</div>
                <hr /><code class="bbcode_code"><div class="java" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">            <span style="color: #7F0055; font-weight: bold;">for</span><span style="color: #000000;">&#40;</span>CakeRecipe recipe <span style="color: #000000;">:</span> recipeSet.<span style="color: #000000;">getAllCakeRecipes</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> 
            <span style="color: #000000;">&#123;</span>
                <span style="color: #7F0055; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>recipe.<span style="color: #000000;">foundWords</span><span style="color: #000000;">&#40;</span>keys<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> 
                <span style="color: #000000;">&#123;</span>
                    searchRecipe.<span style="color: #000000;">add</span><span style="color: #000000;">&#40;</span>recipe<span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
                <span style="color: #000000;">&#125;</span>
                <span style="color: #7F0055; font-weight: bold;">else</span>
                <span style="color: #000000;">&#123;</span>
                    <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ajoptionpane+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">JOptionPane</span></a>.<span style="color: #000000;">showMessageDialog</span><span style="color: #000000;">&#40;</span><span style="color: #7F0055; font-weight: bold;">this</span>,<span style="color: #0000ff;">&quot;No recipe containing search words found.&quot;</span>, <span style="color: #0000ff;">&quot;Error!&quot;</span>,
                                                    <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ajoptionpane+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">JOptionPane</span></a>.<span style="color: #000000;">ERROR_MESSAGE</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
                <span style="color: #000000;">&#125;</span>
&nbsp;
            <span style="color: #000000;">&#125;</span></pre></div></code><hr />
</div> <br />
Suggestions?</div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/whats-wrong-my-code/"><![CDATA[What's Wrong With My Code?]]></category>
			<dc:creator>deeevo</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/whats-wrong-my-code/29639-gui-user-input-error-message.html</guid>
		</item>
		<item>
			<title>A different code runs</title>
			<link>http://www.javaprogrammingforums.com/whats-wrong-my-code/29637-different-code-runs.html</link>
			<pubDate>Fri, 24 May 2013 02:55:40 GMT</pubDate>
			<description><![CDATA[hello friends, need ur help, dnt knw what's wrong. A different code runs(i.e a code i ran previously) instead of the present code on my editor that i...]]></description>
			<content:encoded><![CDATA[<div>hello friends, need ur help, dnt knw what's wrong. A different code runs(i.e a code i ran previously) instead of the present code on my editor that i tried running after coding. here is the present code<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code java:</div>
                <hr /><code class="bbcode_code"><div class="java" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #7F0055; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.*</span><span style="color: #000000;">;</span>
<span style="color: #7F0055; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.event.*</span><span style="color: #000000;">;</span>
<span style="color: #7F0055; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.*</span><span style="color: #000000;">;</span>
&nbsp;
<span style="color: #7F0055; font-weight: bold;">public</span> <span style="color: #7F0055; font-weight: bold;">class</span> gui11 <span style="color: #7F0055; font-weight: bold;">extends</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ajpanel+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">JPanel</span></a><span style="color: #000000;">&#123;</span>
	<span style="color: #7F0055; font-weight: bold;">public</span> <span style="color: #7F0055; font-weight: bold;">void</span> paintComponent<span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Agraphics+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Graphics</span></a> g<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
		<span style="color: #7F0055; font-weight: bold;">super</span>.<span style="color: #000000;">paintComponent</span><span style="color: #000000;">&#40;</span>g<span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
		<span style="color: #7F0055; font-weight: bold;">this</span>.<span style="color: #000000;">setBackground</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acolor+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Color</span></a>.<span style="color: #000000;">WHITE</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
&nbsp;
		g.<span style="color: #000000;">setColor</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acolor+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Color</span></a>.<span style="color: #000000;">BLUE</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
		g.<span style="color: #000000;">drawLine</span><span style="color: #000000;">&#40;</span><span style="color: #cc66cc;">10</span>, <span style="color: #cc66cc;">25</span>, <span style="color: #cc66cc;">200</span>, <span style="color: #cc66cc;">45</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
&nbsp;
		g.<span style="color: #000000;">setColor</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acolor+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Color</span></a>.<span style="color: #000000;">RED</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
		g.<span style="color: #000000;">drawRect</span><span style="color: #000000;">&#40;</span><span style="color: #cc66cc;">10</span>, <span style="color: #cc66cc;">55</span>, <span style="color: #cc66cc;">100</span>, <span style="color: #cc66cc;">30</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
&nbsp;
		g.<span style="color: #000000;">setColor</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acolor+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Color</span></a>.<span style="color: #000000;">GREEN</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
		g.<span style="color: #000000;">fillOval</span><span style="color: #000000;">&#40;</span><span style="color: #cc66cc;">10</span>, <span style="color: #cc66cc;">95</span>, <span style="color: #cc66cc;">100</span>, <span style="color: #cc66cc;">30</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
&nbsp;
		g.<span style="color: #000000;">setColor</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acolor+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Color</span></a>.<span style="color: #000000;">ORANGE</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
		g.<span style="color: #000000;">fill3DRect</span><span style="color: #000000;">&#40;</span><span style="color: #cc66cc;">10</span>, <span style="color: #cc66cc;">160</span>, <span style="color: #cc66cc;">100</span>, <span style="color: #cc66cc;">50</span>, <span style="color: #000066; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
&nbsp;
&nbsp;
	<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #000000;">&#125;</span></pre></div></code><hr />
</div>  the previous code that wouldnt stop running is<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code java:</div>
                <hr /><code class="bbcode_code"><div class="java" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #7F0055; font-weight: bold;">package</span> <span style="color: #006699;">gui</span><span style="color: #000000;">;</span>
<span style="color: #7F0055; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.*</span><span style="color: #000000;">;</span>
<span style="color: #7F0055; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.event.*</span><span style="color: #000000;">;</span>
<span style="color: #7F0055; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.*</span><span style="color: #000000;">;</span>
&nbsp;
<span style="color: #7F0055; font-weight: bold;">public</span> <span style="color: #7F0055; font-weight: bold;">class</span> Gui10 <span style="color: #7F0055; font-weight: bold;">extends</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ajpanel+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">JPanel</span></a><span style="color: #000000;">&#123;</span>
&nbsp;
	<span style="color: #7F0055; font-weight: bold;">public</span> <span style="color: #7F0055; font-weight: bold;">void</span> paintComponent<span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Agraphics+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Graphics</span></a> g<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
		<span style="color: #7F0055; font-weight: bold;">super</span>.<span style="color: #000000;">paintComponent</span> <span style="color: #000000;">&#40;</span>g<span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
		<span style="color: #7F0055; font-weight: bold;">this</span>.<span style="color: #000000;">setBackground</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acolor+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Color</span></a>.<span style="color: #000000;">WHITE</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
&nbsp;
		g.<span style="color: #000000;">setColor</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acolor+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Color</span></a>.<span style="color: #000000;">BLUE</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
		g.<span style="color: #000000;">fillRect</span><span style="color: #000000;">&#40;</span><span style="color: #cc66cc;">25</span>, <span style="color: #cc66cc;">25</span>, <span style="color: #cc66cc;">100</span>, <span style="color: #cc66cc;">30</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
&nbsp;
		g.<span style="color: #000000;">setColor</span><span style="color: #000000;">&#40;</span><span style="color: #7F0055; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acolor+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Color</span></a><span style="color: #000000;">&#40;</span><span style="color: #cc66cc;">190</span>,<span style="color: #cc66cc;">81</span>,<span style="color: #cc66cc;">215</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
		g.<span style="color: #000000;">fillRect</span><span style="color: #000000;">&#40;</span><span style="color: #cc66cc;">25</span>, <span style="color: #cc66cc;">65</span>, <span style="color: #cc66cc;">100</span>, <span style="color: #cc66cc;">30</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
&nbsp;
		g.<span style="color: #000000;">setColor</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acolor+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Color</span></a>.<span style="color: #000000;">RED</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
		g.<span style="color: #000000;">drawString</span><span style="color: #000000;">&#40;</span><span style="color: #0000ff;">&quot;this is some text&quot;</span>, <span style="color: #cc66cc;">25</span>, <span style="color: #cc66cc;">120</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
&nbsp;
	<span style="color: #000000;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #000000;">&#125;</span></pre></div></code><hr />
</div> i'll be gratefull to knw the cause soln, both code are same package. thanks!</div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/whats-wrong-my-code/"><![CDATA[What's Wrong With My Code?]]></category>
			<dc:creator>chized</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/whats-wrong-my-code/29637-different-code-runs.html</guid>
		</item>
		<item>
			<title>Logic-Factory Pattern</title>
			<link>http://www.javaprogrammingforums.com/whats-wrong-my-code/29636-logic-factory-pattern.html</link>
			<pubDate>Fri, 24 May 2013 02:36:17 GMT</pubDate>
			<description>Hi, 
 
we are creating the Common Engine in java to handle the all web service request. 
In that engine contains,  
  session and reference data both...</description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
we are creating the Common Engine in java to handle the all web service request.<br />
In that engine contains, <br />
  session and reference data both values are maintain for all request and for all prj..<br />
  Process Factory to handle all process related to every prj..<br />
<br />
Each time,  will they request to hit the engine or process factory..?<br />
<br />
What is purpose of creating the Factory class..how we have to utilize better?</div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/whats-wrong-my-code/"><![CDATA[What's Wrong With My Code?]]></category>
			<dc:creator>hemakarthik</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/whats-wrong-my-code/29636-logic-factory-pattern.html</guid>
		</item>
		<item>
			<title>Passed array value is null</title>
			<link>http://www.javaprogrammingforums.com/whats-wrong-my-code/29634-passed-array-value-null.html</link>
			<pubDate>Fri, 24 May 2013 00:37:05 GMT</pubDate>
			<description>2nd part of a homework project which we have strict instructions. In the first part, I have another class which builds an Array of Country objects,...</description>
			<content:encoded><![CDATA[<div>2nd part of a homework project which we have strict instructions. In the first part, I have another class which builds an Array of Country objects, which I use to create a Stack. Then the Stack values are supposed to be inserted into the priority Que and sorted alphebetically. Either my stack is not passing the objects correctly, or for whatever reason the priority Que is not receiving them correctly. When I print the array in pQue1 and pQue 2 it returns<br />
<br />
null<br />
<br />
thanks for any help!<br />
<br />
I am very new to java and programming, but from past experiences I feel like the problem lies somewhere in creating the arrays, or somehow I have programmed the methods to pass the array to a completely different instance of priorityQueue??<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.util.Arrays;
&nbsp;
public class Stack {
private int maxSize;        // size of stack array
private Countries&#91;&#93; stackArray;  //  recall:  ‘instance variables’
private int top;            // top of stack
private PriorityQueue pQue1; 
private PriorityQueue pQue2; 
&nbsp;
public Stack(int s)         
  {                
  maxSize = s;             
  stackArray = new Countries&#91;maxSize&#93;;           
  top = -1; 
  pQue1 = new PriorityQueue(maxSize);
  pQue2 = new PriorityQueue(maxSize);
&nbsp;
  } // end constructor
&nbsp;
  public void push(Countries j)  
  {
  // put item on top of stack
  stackArray&#91;++top&#93; = j;
  System.out.println(stackArray&#91;top&#93;);     
&nbsp;
  if (stackArray&#91;top&#93;.getRegionNumber() == 1 )
      buildPQue1(stackArray&#91;top&#93;);
      pQue1.insert(stackArray&#91;top&#93;);
&nbsp;
  if  (stackArray&#91;top&#93;.getRegionNumber() == 2 )
      buildPQue2(stackArray&#91;top&#93;);
  } // end push
&nbsp;
  public void buildPQue1(Countries k)
  {         
      pQue1.insert(k);         
  } // end build PQue1()
&nbsp;
  public void buildPQue2(Countries i)
  {
     pQue1.insert(i);         
  } // end build P Que 2
  // end push()
&nbsp;
&nbsp;
&nbsp;
&nbsp;
public class PriorityQueue extends Queue
{    // array in sorted order, from max at 0 to min at nitems-1
private int maxSize;
private Countries&#91;&#93; queArray;
private Countries&#91;&#93; item;
private int nItems;
&nbsp;
&nbsp;
  public PriorityQueue(int s)    
  {      // constructor             
  super(s);
  maxSize = s;
  queArray = new Countries&#91;maxSize&#93;;
  item = new Countries&#91;maxSize&#93;;
  }//end constructor
&nbsp;
  @Override
  public void insert(Countries item)  {     
  int j;                
  if (nItems==0)                           
  {
      queArray&#91;nItems++&#93; = item; 
     // System.out.println(queArray&#91;nItems&#93;);
  }// end if
  else                                         
  {                     
     for (j=nItems-1; j&gt;=0; j--)    
     {
         if (item.getName().compareTo(queArray&#91;j&#93;.getName()) &lt; 0 )                                
           queArray&#91;j+1&#93; = queArray&#91;j&#93;;                   
        else                                                      
           break;                                            
     } // end for
     if ( j &lt; maxSize)
     {
     queArray&#91;j+1&#93; = item;                                           
     } // end if
       // System.out.print(queArray&#91;j&#93;);
     nItems++;                                                         
&nbsp;
}  // end else (nItems &gt; 0)          
}  // end insert()
&nbsp;
public Countries peekMin()            // peek at minimum item
{ 
return queArray&#91;nItems-1&#93;; 
} // end peek min
&nbsp;
&nbsp;
public void displayQue()
{
System.out.println(queArray&#91;nItems&#93;);
} // end display que
&nbsp;
}  // end class PriorityQ</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>NoobException</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/whats-wrong-my-code/29634-passed-array-value-null.html</guid>
		</item>
		<item>
			<title>Downcasting/Inheritance</title>
			<link>http://www.javaprogrammingforums.com/whats-wrong-my-code/29632-downcasting-inheritance.html</link>
			<pubDate>Fri, 24 May 2013 00:24:03 GMT</pubDate>
			<description>Ok need some help.  I am new to this site.  So not sure best approach. 
 
I have a super class(Shapes), sub class(rectangle) and sub sub class (Box)....</description>
			<content:encoded><![CDATA[<div>Ok need some help.  I am new to this site.  So not sure best approach.<br />
<br />
I have a super class(Shapes), sub class(rectangle) and sub sub class (Box).  I need to be able to print the shapeType for the two subclasses.  I believe I need to use down casting.  however I've attempted and failed!  :mad:<br />
<br />
I am not sure best way to share code.  So I think I have it attached correctly.<br />
<br />
<br />
<a href="http://www.javaprogrammingforums.com/attachments/whats-wrong-my-code/2100d1369354988-downcasting-inheritance-help-txt"  title="Name:  help.txt
Views: 1
Size:  6.6 KB">help.txt</a></div>


	<div style="padding:10px">

	

	

	

	
		<fieldset class="fieldset">
			<legend>Attached Files</legend>
			<ul>
			<li>
	<img class="inlineimg" src="http://www.javaprogrammingforums.com/images/attach/txt.gif" alt="File Type: txt" />
	<a href="http://www.javaprogrammingforums.com/attachments/whats-wrong-my-code/2100d1369354988-downcasting-inheritance-help-txt">help.txt</a> 
(6.6 KB)
</li>
			</ul>
		</fieldset>
	

	</div>
]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/whats-wrong-my-code/"><![CDATA[What's Wrong With My Code?]]></category>
			<dc:creator>john2454</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/whats-wrong-my-code/29632-downcasting-inheritance.html</guid>
		</item>
		<item>
			<title><![CDATA[JRadioButton Won't Respond]]></title>
			<link>http://www.javaprogrammingforums.com/whats-wrong-my-code/29628-jradiobutton-wont-respond.html</link>
			<pubDate>Thu, 23 May 2013 20:26:08 GMT</pubDate>
			<description>Hello! 
So my problem is that my radio buttons are not responding when I click them. I made sure there was an ActionListener, and I think my if...</description>
			<content:encoded><![CDATA[<div>Hello!<br />
So my problem is that my radio buttons are not responding when I click them. I made sure there was an ActionListener, and I think my if statements are fine. So I'm pretty lost as to why they aren't doing their job.<br />
<br />
In case my code is vague, I want the radio buttons to change the color of the font when it is clicked.<br />
<br />
Thank you!<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;">package UserInterface;
&nbsp;
import BusinessModel.Controller;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.*;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
&nbsp;
&nbsp;
public class ProductPanel extends JPanel implements ActionListener, ListSelectionListener 
{
    private Controller ctrl = new Controller();
    private JButton btnInventory;
    private JButton btnAdd;
    private JButton btnReturn;
    private JList lstInventory;
    private JList lstCart;
    private JTextArea txtDetails;
    private JScrollPane scroll;
    private DefaultListModel model;
    private DefaultListModel modelCart;
    private JRadioButton black, blue, red;
&nbsp;
    ProductPanel()
    {
&nbsp;
        // Create Graphical Objects
        ButtonGroup buttonGroup = new ButtonGroup();
&nbsp;
        black = new JRadioButton(&quot;Black&quot;);
        buttonGroup.add(black);
        black.setSelected(true);
&nbsp;
        blue = new JRadioButton(&quot;Blue&quot;);
        buttonGroup.add(blue);
&nbsp;
        red = new JRadioButton(&quot;Red&quot;);
        buttonGroup.add(red);
&nbsp;
        btnInventory = new JButton (&quot;Inventory&quot;);
        if(black.isSelected())
            btnInventory.setForeground(Color.BLACK);
        else if(blue.isSelected())
            btnInventory.setForeground(Color.BLUE);
        else if (red.isSelected())
            btnInventory.setForeground(Color.RED);
        btnInventory.setFont(new Font(&quot;Arial&quot;,Font.BOLD,14));
        btnInventory.setToolTipText(&quot;View Inventory&quot;);
&nbsp;
        btnAdd = new JButton (&quot;Add&quot;);
        if(black.isSelected())
            btnAdd.setForeground(Color.BLACK);
        else if(blue.isSelected())
            btnAdd.setForeground(Color.BLUE);
        else if(red.isSelected())
            btnAdd.setForeground(Color.RED);
        btnAdd.setFont(new Font(&quot;Arial&quot;,Font.BOLD,14));
        btnAdd.setToolTipText(&quot;Add item to cart&quot;);
&nbsp;
        btnReturn = new JButton (&quot;Return&quot;);
        if(black.isSelected())
            btnReturn.setForeground(Color.BLACK);
        else if(blue.isSelected())
            btnReturn.setForeground(Color.BLUE);
        else if(red.isSelected())
            btnReturn.setForeground(Color.RED);
        btnReturn.setFont(new Font(&quot;Arial&quot;,Font.BOLD,14));
        btnReturn.setToolTipText(&quot;Remove item from cart&quot;);
&nbsp;
&nbsp;
        // Product List
        model = new DefaultListModel();
        lstInventory = new JList(model);
        lstInventory.setPreferredSize(new Dimension(300,200));
        lstInventory.setBorder(BorderFactory.createLineBorder(Color.BLACK));
&nbsp;
        // Display details
        txtDetails = new JTextArea(14,30);
        txtDetails.setFont(new Font(&quot;Arial&quot;,Font.PLAIN,12));
        txtDetails.setEditable(false);
        scroll = new JScrollPane(txtDetails);
        scroll.setBorder(BorderFactory.createLineBorder(Color.BLACK));
&nbsp;
        // Labels
        JPanel cartL = new JPanel();
        JLabel cartLabel = new JLabel (&quot;Cart&quot;);
        cartL.add(cartLabel = new JLabel(&quot;User's Cart&quot;));
&nbsp;
        JPanel colorL = new JPanel();
        JLabel colorLabel = new JLabel (&quot;Color&quot;);
        colorL.add(colorLabel = new JLabel(&quot;Choose Font Color&quot;));
&nbsp;
&nbsp;
        // Display Cart
        modelCart = new DefaultListModel();
        lstCart = new JList(modelCart);
        lstCart.setPreferredSize(new Dimension(495,200));
        lstCart.setBorder(BorderFactory.createLineBorder(Color.BLACK));
&nbsp;
        // Register event listeners
        black.addActionListener(this);
        blue.addActionListener(this);
        red.addActionListener(this);
        btnInventory.addActionListener(this);
        btnAdd.addActionListener(this);
        btnReturn.addActionListener(this);
        lstInventory.addListSelectionListener(this);
        lstCart.addListSelectionListener(this);
&nbsp;
&nbsp;
        // Button Panel
        JPanel btnpanel = new JPanel();
        btnpanel.setLayout(new GridLayout(6,1));
        btnpanel.add(btnInventory);
        btnpanel.add(btnAdd);
        btnpanel.add(btnReturn);
        btnpanel.add(colorL);
        btnpanel.add(black);
        btnpanel.add(blue);
        btnpanel.add(red);
&nbsp;
        // Add objects to panel
        add(btnpanel);
        add(lstInventory);
        add(scroll);
        add(cartL);
        add(lstCart);
&nbsp;
    }
&nbsp;
&nbsp;
    public void actionPerformed(ActionEvent event) 
    {
        Object source = event.getSource();
&nbsp;
        if(source == btnInventory)
        {
            model.clear();
            ArrayList &lt;String&gt; myList = ctrl.listContents();
            for (String s : myList)
            {
                model.addElement(s);
            }
        }
        else if (source == btnAdd)
        {
            if(lstInventory.isSelectionEmpty())
                JOptionPane.showMessageDialog(null, &quot;No Product Selected!&quot;);
            else
            {
            String cartID = lstInventory.getSelectedValue().toString();
            String&#91;&#93; fields = cartID.split(&quot;,&quot;);
            ctrl.addToCart(fields&#91;0&#93;);
            modelCart.clear();
            ArrayList &lt;String&gt; myCart = ctrl.listCart();
            for (String s : myCart)
            {
             modelCart.addElement(s);
            }
            }
&nbsp;
        }
        else if (source == btnReturn)
        {
            if(lstCart.isSelectionEmpty())
                JOptionPane.showMessageDialog(null, &quot;No Product Selected!&quot;);
            else
            {
            String cartID = lstCart.getSelectedValue().toString();
            String&#91;&#93; fields = cartID.split(&quot;,&quot;);
            ctrl.removeFromCart(fields&#91;0&#93;);
            modelCart.clear();
            ArrayList &lt;String&gt; myCart = ctrl.listCart();
&nbsp;
            for(String s : myCart)
            {
                modelCart.addElement(s);
            }
            }
        }
    }
&nbsp;
    public void valueChanged(ListSelectionEvent e) 
    {
        //Read list and get product key
        String ID = lstInventory.getSelectedValue().toString();
        String&#91;&#93; fields = ID.split(&quot;,&quot;);
        txtDetails.setText(ctrl.getProductInfo(fields&#91;0&#93;));
    }
}</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>SynergY</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/whats-wrong-my-code/29628-jradiobutton-wont-respond.html</guid>
		</item>
		<item>
			<title>Several questions about my code</title>
			<link>http://www.javaprogrammingforums.com/whats-wrong-my-code/29626-several-questions-about-my-code.html</link>
			<pubDate>Thu, 23 May 2013 20:03:53 GMT</pubDate>
			<description>Hello, 
 
The comments in the code are my specified questions about the code. Please help me with finding the proper solution. I searched on the web,...</description>
			<content:encoded><![CDATA[<div>Hello,<br />
<br />
The comments in the code are my specified questions about the code. Please help me with finding the proper solution. I searched on the web, but I did not find the right solution for my problem. I couldn't find the right way to implement the information I found on the internet. So that's why I need some people who have more experience with Java who are willing to help me.<br />
<br />
Could you help me please?<br />
<br />
This is my code (with comments/questions):<br />
<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code Java:</div>
                <hr /><code class="bbcode_code"><div class="java" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;
<span style="color: #7F0055; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Scanner</span><span style="color: #000000;">;</span>
<span style="color: #7F0055; font-weight: bold;">import</span> <span style="color: #006699;">java.util.ArrayList</span><span style="color: #000000;">;</span>
&nbsp;
<span style="color: #7F0055; font-weight: bold;">class</span> Bank<span style="color: #000000;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">double</span> balance<span style="color: #000000;">;</span>
  <span style="color: #3F7F5F; font-style: italic;">//Account account;</span>
  ArrayList<span style="color: #000000;">&lt;</span>Account<span style="color: #000000;">&gt;</span>account <span style="color: #000000;">=</span> <span style="color: #7F0055; font-weight: bold;">new</span> ArrayList<span style="color: #000000;">&lt;</span>Account<span style="color: #000000;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
  CommandReader commandReader<span style="color: #000000;">;</span>
&nbsp;
  Bank<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
    commandReader <span style="color: #000000;">=</span> <span style="color: #7F0055; font-weight: bold;">new</span> CommandReader<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
  <span style="color: #000000;">&#125;</span>
&nbsp;
  <span style="color: #7F0055; font-weight: bold;">void</span> run<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
    commandReader.<span style="color: #000000;">run</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>  <span style="color: #3F7F5F; font-style: italic;">// The commandReader is a class which already should be fine</span>
  <span style="color: #000000;">&#125;</span>
&nbsp;
  <span style="color: #7F0055; font-weight: bold;">void</span> enroll<span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> name<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
    <span style="color: #7F0055; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>account.<span style="color: #000000;">equals</span><span style="color: #000000;">&#40;</span>account<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>  <span style="color: #3F7F5F; font-style: italic;">//Why is this always true? I doesn't want to create two of the same accounts. In the commandReader the input is enroll Name</span>
      <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #000000;">out</span>.<span style="color: #000000;">println</span><span style="color: #000000;">&#40;</span><span style="color: #0000ff;">&quot;already enrolled&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
    <span style="color: #000000;">&#125;</span> <span style="color: #7F0055; font-weight: bold;">else</span> <span style="color: #000000;">&#123;</span>
      account.<span style="color: #000000;">add</span><span style="color: #000000;">&#40;</span>account<span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span> <span style="color: #3F7F5F; font-style: italic;">//This does also not work properly! when enroll Name is typed in by the user, there should be enrolled an account with name = Name and balance = 0</span>
    <span style="color: #000000;">&#125;</span>
  <span style="color: #000000;">&#125;</span>
&nbsp;
  <span style="color: #7F0055; font-weight: bold;">void</span> print<span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> name<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
    <span style="color: #7F0055; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>account.<span style="color: #000000;">equals</span><span style="color: #000000;">&#40;</span>account<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
      <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #000000;">out</span>.<span style="color: #000000;">println</span><span style="color: #000000;">&#40;</span><span style="color: #0000ff;">&quot;Account of &quot;</span><span style="color: #000000;">+</span>name<span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
      <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #000000;">out</span>.<span style="color: #000000;">println</span><span style="color: #000000;">&#40;</span><span style="color: #0000ff;">&quot;  balance: &quot;</span><span style="color: #000000;">+</span>balance<span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
    <span style="color: #000000;">&#125;</span> <span style="color: #7F0055; font-weight: bold;">else</span> <span style="color: #000000;">&#123;</span>
      <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #000000;">out</span>.<span style="color: #000000;">println</span><span style="color: #000000;">&#40;</span><span style="color: #0000ff;">&quot;no such name &quot;</span><span style="color: #000000;">+</span>name<span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
    <span style="color: #000000;">&#125;</span>
  <span style="color: #000000;">&#125;</span>
&nbsp;
  <span style="color: #7F0055; font-weight: bold;">void</span> printAll<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
    <span style="color: #7F0055; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>account.<span style="color: #000000;">equals</span><span style="color: #000000;">&#40;</span>account<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
      <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #000000;">out</span>.<span style="color: #000000;">println</span><span style="color: #000000;">&#40;</span>account<span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span> <span style="color: #3F7F5F; font-style: italic;">//What I want to print here are all the accounts and they should be printed the same as the method above prints the accounts</span>
    <span style="color: #000000;">&#125;</span>
  <span style="color: #000000;">&#125;</span>
&nbsp;
  <span style="color: #7F0055; font-weight: bold;">public</span> <span style="color: #7F0055; font-weight: bold;">static</span> <span style="color: #7F0055; font-weight: bold;">void</span> main<span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> args<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
      <span style="color: #7F0055; font-weight: bold;">new</span> Bank<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #000000;">run</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
  <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #7F0055; font-weight: bold;">class</span> Account<span style="color: #000000;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">double</span> balance<span style="color: #000000;">;</span>
  <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> name<span style="color: #000000;">;</span>
&nbsp;
  Account<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
    bank <span style="color: #000000;">=</span> <span style="color: #7F0055; font-weight: bold;">new</span> Bank<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span> <span style="color: #3F7F5F; font-style: italic;">//Is this necessary?</span>
  <span style="color: #000000;">&#125;</span>
&nbsp;
  <span style="color: #7F0055; font-weight: bold;">void</span> user<span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> name, <span style="color: #000066; font-weight: bold;">double</span> balance<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
    <span style="color: #7F0055; font-weight: bold;">this</span>.<span style="color: #000000;">name</span> <span style="color: #000000;">=</span> name<span style="color: #000000;">;</span>
    <span style="color: #7F0055; font-weight: bold;">this</span>.<span style="color: #000000;">balance</span> <span style="color: #000000;">=</span> balance<span style="color: #000000;">;</span>  <span style="color: #3F7F5F; font-style: italic;">//I think I don't understand it yet. The name and balance is what I want to store of the accounts</span>
  <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></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>ProgrammerNoobE</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/whats-wrong-my-code/29626-several-questions-about-my-code.html</guid>
		</item>
		<item>
			<title>What gives?</title>
			<link>http://www.javaprogrammingforums.com/whats-wrong-my-code/29625-what-gives.html</link>
			<pubDate>Thu, 23 May 2013 20:01:40 GMT</pubDate>
			<description>Hello, I am trying to get to grips with Java and specifically at this moment with text input, I wrote this with some help from Dr Google: 
 
...</description>
			<content:encoded><![CDATA[<div>Hello, I am trying to get to grips with Java and specifically at this moment with text input, I wrote this with some help from Dr Google:<br />
<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code java:</div>
                <hr /><code class="bbcode_code"><div class="java" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #7F0055; font-weight: bold;">package</span> <span style="color: #006699;">stringvars</span><span style="color: #000000;">;</span>
&nbsp;
<span style="color: #7F0055; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Scanner</span><span style="color: #000000;">;</span>
&nbsp;
<span style="color: #7F0055; font-weight: bold;">public</span> <span style="color: #7F0055; font-weight: bold;">class</span> StringVariables <span style="color: #000000;">&#123;</span>
&nbsp;
  <span style="color: #7F0055; font-weight: bold;">public</span> <span style="color: #7F0055; font-weight: bold;">static</span> <span style="color: #7F0055; font-weight: bold;">void</span> main<span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> args<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
&nbsp;
  	  Scanner user_input <span style="color: #000000;">=</span> <span style="color: #7F0055; font-weight: bold;">new</span> Scanner<span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #000000;">in</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
&nbsp;
  	  <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> first_name<span style="color: #000000;">;</span>
  	  <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #000000;">out</span>.<span style="color: #000000;">print</span><span style="color: #000000;">&#40;</span><span style="color: #0000ff;">&quot;Enter your first name: &quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
  	  first_name <span style="color: #000000;">=</span> user_input.<span style="color: #000000;">next</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
&nbsp;
  	  <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> family_name<span style="color: #000000;">;</span>
  	  <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #000000;">out</span>.<span style="color: #000000;">print</span><span style="color: #000000;">&#40;</span><span style="color: #0000ff;">&quot;Enter family name: &quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
  	  family_name <span style="color: #000000;">=</span> user_input.<span style="color: #000000;">next</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
&nbsp;
  	  <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> full_name<span style="color: #000000;">;</span>
  	  full_name <span style="color: #000000;">=</span> first_name <span style="color: #000000;">+</span> <span style="color: #0000ff;">&quot; &quot;</span> <span style="color: #000000;">+</span> family_name<span style="color: #000000;">;</span>
&nbsp;
  	  <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #000000;">out</span>.<span style="color: #000000;">println</span><span style="color: #000000;">&#40;</span><span style="color: #0000ff;">&quot;You are &quot;</span> <span style="color: #000000;">+</span> full_name<span style="color: #000000;">&#41;</span><span style="color: #000000;">;</span>
  <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></code><hr />
</div> <br />
It did not work…. So I tinkered with it and low and behold, when I removed the top line (package stringvars;) it worked &#9786;<br />
<br />
So – my question is why?<br />
<br />
Thanks in advance for any help – Ian &#9786;</div>

]]></content:encoded>
			<category domain="http://www.javaprogrammingforums.com/whats-wrong-my-code/"><![CDATA[What's Wrong With My Code?]]></category>
			<dc:creator>iansmiler</dc:creator>
			<guid isPermaLink="true">http://www.javaprogrammingforums.com/whats-wrong-my-code/29625-what-gives.html</guid>
		</item>
	</channel>
</rss>
