<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>KirkHings.com &#187; Kirk</title>
	<atom:link href="http://kirkhings.com/author/admin/feed/" rel="self" type="application/rss+xml" />
	<link>http://kirkhings.com</link>
	<description>The '-berger' part trips up so many folks that I sometimes simplify my name for you. Yes, just for you.</description>
	<lastBuildDate>Sat, 13 Jun 2009 18:35:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Phrase-O-Matic Consultant Wisdom via Java</title>
		<link>http://kirkhings.com/code/java/phrase-o-matic-consultant-wisdom-via-java/419/</link>
		<comments>http://kirkhings.com/code/java/phrase-o-matic-consultant-wisdom-via-java/419/#comments</comments>
		<pubDate>Sat, 13 Jun 2009 18:35:59 +0000</pubDate>
		<dc:creator>Kirk</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[head first java]]></category>
		<category><![CDATA[randomizer]]></category>
		<category><![CDATA[self-instructional challenge]]></category>

		<guid isPermaLink="false">http://kirkhings.com/?p=419</guid>
		<description><![CDATA[ photo credit: schedetzki
Challenge: Create three lists of buzzwords typically used by business consultants. Randomly select three words and put in a sentence to form something ridiculous that a business consultant might say with an air of authority.

My solution:

package phraseomatic;

/**
 *
 * @author kirkster
 */
public class Main {

    /**
    [...]


Related posts:<ul><li><a href='http://kirkhings.com/code/java/bottles-of-beer-song-via-java/388/' rel='bookmark' title='Permanent Link: Bottles of Beer Song via Java'>Bottles of Beer Song via Java</a> <small> photo credit: NUCO This programming challenge is from the...</small></li>
<li><a href='http://kirkhings.com/code/java/plain-and-recursive-factorials-with-full-print-enhancements/239/' rel='bookmark' title='Permanent Link: Plain and Recursive Factorials with Full Print Enhancements'>Plain and Recursive Factorials with Full Print Enhancements</a> <small> photo credit: gadl This programming challenge is from a...</small></li>
<li><a href='http://kirkhings.com/code/javascript/random-image-display-with-javascript/406/' rel='bookmark' title='Permanent Link: Random Image Display with JavaScript'>Random Image Display with JavaScript</a> <small> photo credit: davidChief This programming challenge is from a...</small></li>
<li><a href='http://kirkhings.com/code/javascript/random-bingo-card-generator-with-ajax-reset/224/' rel='bookmark' title='Permanent Link: Random BINGO Card Generator with Ajax Reset'>Random BINGO Card Generator with Ajax Reset</a> <small> photo credit: Keees This programming challenge is from a...</small></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="borrowedPic"><a href="http://www.flickr.com/photos/28590840@N08/2660235237/" title="Peter Schedetzki" target="_blank"><img src="http://farm4.static.flickr.com/3065/2660235237_2c202c38a3.jpg" alt="Peter Schedetzki" border="0" /></a><br /><small><a href="http://creativecommons.org/licenses/by-nd/2.0/" title="Attribution-NoDerivs License" target="_blank"><img src="http://kirkhings.com/wp-content/plugins/photo-dropper/images/cc.png" alt="Creative Commons License" border="0" width="16" height="16" align="absmiddle" /></a> <a href="http://www.photodropper.com/photos/" target="_blank">photo</a> credit: <a href="http://www.flickr.com/photos/28590840@N08/2660235237/" title="schedetzki" target="_blank">schedetzki</a></small></div>
<blockquote><p>Challenge: Create three lists of buzzwords typically used by business consultants. Randomly select three words and put in a sentence to form something ridiculous that a business consultant might say with an air of authority.
</p></blockquote>
<p>My solution:</p>
<pre class="brush: java;">
package phraseomatic;

/**
 *
 * @author kirkster
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // create three word sets to build from
        String[] wordListOne = {&quot;24/7&quot;, &quot;multi-Tier&quot;, &quot;30,000 foot&quot;, &quot;B2B&quot;, &quot;win-win&quot;, &quot;front-end&quot;, &quot;web-based&quot;, &quot;pervasive&quot;, &quot;smart&quot;, &quot;six-sigma&quot;, &quot;critical-path&quot;, &quot;dynamic&quot;};
        String[] wordListTwo = {&quot;empowered&quot;, &quot;sticky&quot;, &quot;value-added&quot;, &quot;oriented&quot;, &quot;centric&quot;, &quot;distributed&quot;, &quot;clustered&quot;, &quot;branded&quot;, &quot;outside-the-box&quot;, &quot;positioned&quot;, &quot;networked&quot;, &quot;focused&quot;, &quot;leveraged&quot;, &quot;aligned&quot;, &quot;targeted&quot;, &quot;shared&quot;, &quot;cooperative&quot;, &quot;accelerated&quot;, &quot;semantic&quot;};
        String[] wordListThree = {&quot;process&quot;, &quot;tipping-point&quot;, &quot;solution&quot;, &quot;architecture&quot;, &quot;core competency&quot;, &quot;strategy&quot;, &quot;mindshare&quot;, &quot;portal&quot;, &quot;space&quot;, &quot;vision&quot;, &quot;paradigm&quot;, &quot;mission&quot;};

        // determine how many words in each list
        int oneLength = wordListOne.length;
        int twoLength = wordListTwo.length;
        int threeLength = wordListThree.length;

        // generate three random numbers
        int rand1 = (int) (Math.random() * oneLength);
        int rand2 = (int) (Math.random() * twoLength);
        int rand3 = (int) (Math.random() * threeLength);

        // build a phrase
        String phrase = wordListOne[rand1] + &quot; &quot; + wordListTwo[rand2] + &quot; &quot; + wordListThree[rand3];

        // print out the phrase
        System.out.println(&quot;Consultant says: \&quot;We need a &quot; + phrase + &quot;!\&quot;&quot;);
    }

}
</pre>
<p>Here is the output:</p>
<div id="attachment_420" class="wp-caption alignleft" style="width: 410px"><img src="http://kirkhings.com/wp-content/uploads/phraseomatic.png" alt="Phrase-O-Matic pumps out business consultant wisdom" title="phraseomatic" width="400" height="414" class="size-full wp-image-420" /><p class="wp-caption-text">Phrase-O-Matic pumps out business consultant wisdom</p></div>
<p>This programming challenge is from the Head First Java book, which I studied and practiced spring 2009. The end result itself is not terribly sexy, but I liked the algorithm construction process. My programming curriculum changed course during the first year, and they eliminated our Java classes. I was still curious about Java, so I took it upon myself to self-learn Java. This was one of my first products.</p>
<p>I post these self-instructional challenges for a few reasons. One is to demonstrate my programming learning, experience, and progression. Another reason is to make sure my code and solutions are indexed by search engines, so that other beginning programmers may get help if they need it. Finally, self-instructional challenges are interesting and different than academic challenges because I sought, discovered, and performed them on my own volition without anyone else telling me to do so. I did it because I wanted to learn and practice.</p>


<p>Related posts:<ul><li><a href='http://kirkhings.com/code/java/bottles-of-beer-song-via-java/388/' rel='bookmark' title='Permanent Link: Bottles of Beer Song via Java'>Bottles of Beer Song via Java</a> <small> photo credit: NUCO This programming challenge is from the...</small></li>
<li><a href='http://kirkhings.com/code/java/plain-and-recursive-factorials-with-full-print-enhancements/239/' rel='bookmark' title='Permanent Link: Plain and Recursive Factorials with Full Print Enhancements'>Plain and Recursive Factorials with Full Print Enhancements</a> <small> photo credit: gadl This programming challenge is from a...</small></li>
<li><a href='http://kirkhings.com/code/javascript/random-image-display-with-javascript/406/' rel='bookmark' title='Permanent Link: Random Image Display with JavaScript'>Random Image Display with JavaScript</a> <small> photo credit: davidChief This programming challenge is from a...</small></li>
<li><a href='http://kirkhings.com/code/javascript/random-bingo-card-generator-with-ajax-reset/224/' rel='bookmark' title='Permanent Link: Random BINGO Card Generator with Ajax Reset'>Random BINGO Card Generator with Ajax Reset</a> <small> photo credit: Keees This programming challenge is from a...</small></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://kirkhings.com/code/java/phrase-o-matic-consultant-wisdom-via-java/419/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Math Tutor Enhanced</title>
		<link>http://kirkhings.com/code/c/math-tutor-enhanced/417/</link>
		<comments>http://kirkhings.com/code/c/math-tutor-enhanced/417/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 04:06:59 +0000</pubDate>
		<dc:creator>Kirk</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[academic challenge]]></category>

		<guid isPermaLink="false">http://kirkhings.com/?p=417</guid>
		<description><![CDATA[ photo credit: foundphotoslj
4.9: This is a modification of Chapter 3&#8217;s Problem 15, which was:
Write a program that can be used as a math tutor for a young student. The program should display two random numbers to be added, such as 

   247
+ 129
------

The program should then pause while the student works on [...]


Related posts:<ul><li><a href='http://kirkhings.com/code/c/math-tutor/331/' rel='bookmark' title='Permanent Link: Math Tutor'>Math Tutor</a> <small> photo credit: *Zara This programming challenge is from an...</small></li>
<li><a href='http://kirkhings.com/code/c/saving-numbers-to-a-file/348/' rel='bookmark' title='Permanent Link: Saving Numbers to a File'>Saving Numbers to a File</a> <small> photo credit: Mykl Roventine This programming challenge is from...</small></li>
<li><a href='http://kirkhings.com/code/c/interest-earned/341/' rel='bookmark' title='Permanent Link: Interest Earned'>Interest Earned</a> <small> photo credit: conorwithonen This programming challenge is from an...</small></li>
<li><a href='http://kirkhings.com/code/c/box-office-ticket-sales/159/' rel='bookmark' title='Permanent Link: Box Office Ticket Sales'>Box Office Ticket Sales</a> <small> photo credit: © Natalia Balcerska Photography This programming challenge...</small></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="borrowedPic"><a href="http://www.flickr.com/photos/82312837@N00/466713478/" title="Teaching Math or Something" target="_blank"><img src="http://farm1.static.flickr.com/193/466713478_eb670b9ecd.jpg" alt="Teaching Math or Something" border="0" /></a><br /><small><a href="http://creativecommons.org/licenses/by/2.0/" title="Attribution License" target="_blank"><img src="http://kirkhings.com/wp-content/plugins/photo-dropper/images/cc.png" alt="Creative Commons License" border="0" width="16" height="16" align="absmiddle" /></a> <a href="http://www.photodropper.com/photos/" target="_blank">photo</a> credit: <a href="http://www.flickr.com/photos/82312837@N00/466713478/" title="foundphotoslj" target="_blank">foundphotoslj</a></small></div>
<blockquote><p>4.9: This is a modification of Chapter 3&#8217;s Problem 15, which was:</p>
<p>Write a program that can be used as a math tutor for a young student. The program should display two random numbers to be added, such as </p>
<pre>
   247
+ 129
------
</pre>
<p>The program should then pause while the student works on the problem. When the student is ready to check the answer, he or she can press a key and the program will display the correct solution, for example:</p>
<pre>
   247
+ 129
------
   376
</pre>
<p>This time, write a program that can be used as a math tutor for a young student. The program should display two random numbers that are to be added. The program should wait for the student to enter the answer. If the answer is correct, a message of congratulations should be printed. If the answer is incorrect, a message should be printed showing the correct answer.
</p></blockquote>
<p>My solution:</p>
<pre class="brush: cpp;">
/* Chapter 4 Challenge 9
   Written by Kirk Hingsberger
   October 3, 2007
   Math Tutor - Enhanced
*/

#include &lt;iomanip&gt;
#include &lt;cstdlib&gt;
#include &lt;ctime&gt;
#include &lt;iostream&gt;
using namespace std;

int main()
{
  char ch;
  srand(time(0));
  const int SEED = 999;
  int num1, num2, num3, answer;

  num1 = 1 + rand() % SEED;
  num2 = 1 + rand() % SEED;

  cout &lt;&lt; &quot;Enter your answer after the problem appears:&quot; &lt;&lt; endl;
  cout &lt;&lt; setw(5) &lt;&lt; num1 &lt;&lt; endl;
  cout &lt;&lt; &quot;+ &quot; &lt;&lt; setw(3) &lt;&lt; num2 &lt;&lt; endl;
  cout &lt;&lt; &quot;_____&quot; &lt;&lt; endl;
  cin &gt;&gt; answer;
  num3 = num1 + num2;
  cin.get(ch);

  cout &lt;&lt; setw(5) &lt;&lt; num3 &lt;&lt; &quot; is the correct answer, &quot;;

  if (answer == num3)
    {
      cout &lt;&lt; &quot;great job!&quot; &lt;&lt; endl;
    }
  else if (answer &gt; num3)
    {
      cout &lt;&lt; &quot;your answer (&quot; &lt;&lt; answer &lt;&lt; &quot;) was too high.&quot; &lt;&lt; endl;
    }
  else
    {
      cout &lt;&lt; &quot;your answer (&quot; &lt;&lt; answer &lt;&lt; &quot;) was too low.&quot; &lt;&lt; endl;
    }

  return 0;
}
</pre>
<p>Note: This programming challenge is from an initial C++ programming course I took in Fall 2007. The Chapter (4) was titled &#8220;Making Decisions&#8221;.</p>
<p>I post these old academic challenges for a few reasons. One is to demonstrate my programming learning, experience, and progression. Another reason is to make sure my code and solutions are indexed by search engines, so that other beginning programmers may get help if they need it.</p>


<p>Related posts:<ul><li><a href='http://kirkhings.com/code/c/math-tutor/331/' rel='bookmark' title='Permanent Link: Math Tutor'>Math Tutor</a> <small> photo credit: *Zara This programming challenge is from an...</small></li>
<li><a href='http://kirkhings.com/code/c/saving-numbers-to-a-file/348/' rel='bookmark' title='Permanent Link: Saving Numbers to a File'>Saving Numbers to a File</a> <small> photo credit: Mykl Roventine This programming challenge is from...</small></li>
<li><a href='http://kirkhings.com/code/c/interest-earned/341/' rel='bookmark' title='Permanent Link: Interest Earned'>Interest Earned</a> <small> photo credit: conorwithonen This programming challenge is from an...</small></li>
<li><a href='http://kirkhings.com/code/c/box-office-ticket-sales/159/' rel='bookmark' title='Permanent Link: Box Office Ticket Sales'>Box Office Ticket Sales</a> <small> photo credit: © Natalia Balcerska Photography This programming challenge...</small></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://kirkhings.com/code/c/math-tutor-enhanced/417/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Time Calculator</title>
		<link>http://kirkhings.com/code/c/time-calculator/415/</link>
		<comments>http://kirkhings.com/code/c/time-calculator/415/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 03:14:02 +0000</pubDate>
		<dc:creator>Kirk</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[academic challenge]]></category>

		<guid isPermaLink="false">http://kirkhings.com/?p=415</guid>
		<description><![CDATA[ photo credit: FABIOLA MEDEIROS- direção de arte
This programming challenge is from an initial C++ programming course I took in Fall 2007. The Chapter (4) was titled &#8220;Making Decisions&#8221;.
I post these old academic challenges for a few reasons. One is to demonstrate my programming learning, experience, and progression. Another reason is to make sure my [...]


Related posts:<ul><li><a href='http://kirkhings.com/code/c/interest-earned/341/' rel='bookmark' title='Permanent Link: Interest Earned'>Interest Earned</a> <small> photo credit: conorwithonen This programming challenge is from an...</small></li>
<li><a href='http://kirkhings.com/code/c/test-scores-and-letter-grade/413/' rel='bookmark' title='Permanent Link: Test Scores and Letter Grade'>Test Scores and Letter Grade</a> <small> photo credit: quinn.anya This programming challenge is from an...</small></li>
<li><a href='http://kirkhings.com/code/c/math-tutor-enhanced/417/' rel='bookmark' title='Permanent Link: Math Tutor Enhanced'>Math Tutor Enhanced</a> <small> photo credit: foundphotoslj 4.9: This is a modification of...</small></li>
<li><a href='http://kirkhings.com/code/c/box-office-ticket-sales/159/' rel='bookmark' title='Permanent Link: Box Office Ticket Sales'>Box Office Ticket Sales</a> <small> photo credit: © Natalia Balcerska Photography This programming challenge...</small></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="borrowedPic"><a href="http://www.flickr.com/photos/66355718@N00/206950948/" title="TIME" target="_blank"><img src="http://farm1.static.flickr.com/79/206950948_6c822f621f.jpg" alt="TIME" border="0" /></a><br /><small><a href="http://creativecommons.org/licenses/by/2.0/" title="Attribution License" target="_blank"><img src="http://kirkhings.com/wp-content/plugins/photo-dropper/images/cc.png" alt="Creative Commons License" border="0" width="16" height="16" align="absmiddle" /></a> <a href="http://www.photodropper.com/photos/" target="_blank">photo</a> credit: <a href="http://www.flickr.com/photos/66355718@N00/206950948/" title="FABIOLA MEDEIROS- direção de arte" target="_blank">FABIOLA MEDEIROS- direção de arte</a></small></div>
<p>This programming challenge is from an initial C++ programming course I took in Fall 2007. The Chapter (4) was titled &#8220;Making Decisions&#8221;.</p>
<p>I post these old academic challenges for a few reasons. One is to demonstrate my programming learning, experience, and progression. Another reason is to make sure my code and solutions are indexed by search engines, so that other beginning programmers may get help if they need it.</p>
<blockquote><p>4.7: Write a program that asks the user to enter a number of seconds. </p>
<p>There are 60 seconds in a minute. If the number of seconds entered by the user is greater than or equal to 60, the program should display the number of minutes in that many seconds.</p>
<p>There are 3,600 seconds in an hour. If the number of seconds entered by the user is greater than or equal to 3,600, the program should display the number of hours in that many seconds.</p>
<p>There are 86,400 seconds in a day. If the number of seconds entered by the user is greater than or equal to 86,400, the program should display the number of days in that many seconds.
</p></blockquote>
<p>My solution:</p>
<pre class="brush: cpp;">
/* Chapter 4 Challenge 7
   Written by Kirk Hingsberger
   October 2, 2007
   Time Calculator
*/

#include &lt;iostream&gt;
using namespace std;

int main()
{
  int seconds;
  float minutes, hours, days;

  cout &lt;&lt; &quot;Please enter a number of seconds.&quot; &lt;&lt; endl;
  cin &gt;&gt; seconds;

  if (seconds &gt;= 86400)
    {
      days = seconds / 86400.0;
      cout &lt;&lt; &quot;You entered &quot; &lt;&lt; seconds &lt;&lt; &quot;, which equals &quot;
	   &lt;&lt; days &lt;&lt; &quot; days.&quot; &lt;&lt; endl;
    }

  else if (seconds &gt;= 3600)
    {
      hours = seconds / 3600.0;
      cout &lt;&lt; &quot;You entered &quot; &lt;&lt; seconds &lt;&lt; &quot;, which equals &quot;
	   &lt;&lt; hours &lt;&lt; &quot; hours.&quot; &lt;&lt; endl;
    }
  else if (seconds &gt;= 60)
    {
      minutes = seconds / 60.0;
      cout &lt;&lt; &quot;You entered &quot; &lt;&lt; seconds &lt;&lt; &quot;, which equals &quot;
	   &lt;&lt; minutes &lt;&lt; &quot; minutes.&quot; &lt;&lt; endl;
    }
  else
    cout &lt;&lt; &quot;You entered &quot; &lt;&lt; seconds &lt;&lt; &quot; seconds.&quot; &lt;&lt; endl;

  return 0;
}
</pre>
<p>Here is the capture script I turned in for grading:</p>
<pre class="brush: cpp;">
Script started on Tue 02 Oct 2007 12:06:37 PM MDT
$ cat chap4chlg7.cc
/* Chapter 4 Challenge 7
   Written by Kirk Hingsberger
   October 2, 2007
   Time Calculator
*/

#include &lt;iostream&gt;
using namespace std;

int main()
{
  int seconds;
  float minutes, hours, days;

  cout &lt;&lt; &quot;Please enter a number of seconds.&quot; &lt;&lt; endl;
  cin &gt;&gt; seconds;

  if (seconds &gt;= 86400)
    {
      days = seconds / 86400.0;
      cout &lt;&lt; &quot;You entered &quot; &lt;&lt; seconds &lt;&lt; &quot;, which equals &quot;
	   &lt;&lt; days &lt;&lt; &quot; days.&quot; &lt;&lt; endl;
    }

  else if (seconds &gt;= 3600)
    {
      hours = seconds / 3600.0;
      cout &lt;&lt; &quot;You entered &quot; &lt;&lt; seconds &lt;&lt; &quot;, which equals &quot;
	   &lt;&lt; hours &lt;&lt; &quot; hours.&quot; &lt;&lt; endl;
    }
  else if (seconds &gt;= 60)
    {
      minutes = seconds / 60.0;
      cout &lt;&lt; &quot;You entered &quot; &lt;&lt; seconds &lt;&lt; &quot;, which equals &quot;
	   &lt;&lt; minutes &lt;&lt; &quot; minutes.&quot; &lt;&lt; endl;
    }
  else
    cout &lt;&lt; &quot;You entered &quot; &lt;&lt; seconds &lt;&lt; &quot; seconds.&quot; &lt;&lt; endl;

  return 0;
}
$ g++ -o chap4chlg7 chap4chlg7.cc -s
$ chap4chlg7
Please enter a number of seconds.
59
You entered 59 seconds.
$ chap4chlg7
Please enter a number of seconds.
62
You entered 62, which equals 1.03333 minutes.
$ chap4chlg7
Please enter a number of seconds.
3599
You entered 3599, which equals 59.9833 minutes.
$ chap4chlg7
Please enter a number of seconds.
3604
You entered 3604, which equals 1.00111 hours.
$ chap4chlg7
Please enter a number of seconds.
86399
You entered 86399, which equals 23.9997 hours.
$ chap4chlg7
Please enter a number of seconds.
86401
You entered 86401, which equals 1.00001 days.
$ chap4chlg7
Please enter a number of seconds.
123456789
You entered 123456789, which equals 1428.9 days.
$ exit
exit

Script done on Tue 02 Oct 2007 12:07:33 PM MDT
</pre>
<p>I later went back and expanded my solution to output in more formats at each level:</p>
<pre class="brush: cpp;">
/* Chapter 4 Challenge 7 (Expanded Solution)
   Written by Kirk Hingsberger
   October 2, 2007
   Time Calculator
*/

#include &lt;iomanip&gt;
#include &lt;iostream&gt;
using namespace std;

int main()
{
  int seconds;
  int minutes, hours, days;

  cout &lt;&lt; &quot;Please enter a number of seconds.&quot; &lt;&lt; endl;
  cin &gt;&gt; seconds;

  if (seconds &gt;= 86400)
    {
      days = seconds / 86400;
      cout &lt;&lt; &quot;Number of days: &quot; &lt;&lt; setw(8) &lt;&lt; days &lt;&lt; endl;
      seconds = seconds % 86400;
      hours = seconds / 3600;
      cout &lt;&lt; &quot;Number of hours: &quot; &lt;&lt; setw(7) &lt;&lt; hours &lt;&lt; endl;
      seconds = seconds % 3600;
      minutes = seconds / 60;
      cout &lt;&lt; &quot;Number of minutes: &quot; &lt;&lt; setw(5) &lt;&lt; minutes &lt;&lt; endl;
      seconds = seconds % 60;
      cout &lt;&lt; &quot;Number of seconds: &quot; &lt;&lt; setw(5) &lt;&lt; seconds &lt;&lt; endl;
    }
  else if (seconds &gt;= 3600)
    {
      hours = seconds / 3600;
      cout &lt;&lt; &quot;Number of hours: &quot; &lt;&lt; setw(7) &lt;&lt; hours &lt;&lt; endl;
      seconds = seconds % 3600;
      minutes = seconds / 60;
      cout &lt;&lt; &quot;Number of minutes: &quot; &lt;&lt; setw(5) &lt;&lt; minutes &lt;&lt; endl;
      seconds = seconds % 60;
      cout &lt;&lt; &quot;Number of seconds: &quot; &lt;&lt; setw(5) &lt;&lt; seconds &lt;&lt; endl;
    }
  else if (seconds &gt;= 60)
    {
      minutes = seconds / 60;
      cout &lt;&lt; &quot;Number of minutes: &quot; &lt;&lt; setw(5) &lt;&lt; minutes &lt;&lt; endl;
      seconds = seconds % 60;
      cout &lt;&lt; &quot;Number of seconds: &quot; &lt;&lt; setw(5) &lt;&lt; seconds &lt;&lt; endl;
    }
  else
    {
      cout &lt;&lt; &quot;Number of seconds: &quot; &lt;&lt; setw(5) &lt;&lt; seconds &lt;&lt; endl;
    }

  return 0;
}
</pre>


<p>Related posts:<ul><li><a href='http://kirkhings.com/code/c/interest-earned/341/' rel='bookmark' title='Permanent Link: Interest Earned'>Interest Earned</a> <small> photo credit: conorwithonen This programming challenge is from an...</small></li>
<li><a href='http://kirkhings.com/code/c/test-scores-and-letter-grade/413/' rel='bookmark' title='Permanent Link: Test Scores and Letter Grade'>Test Scores and Letter Grade</a> <small> photo credit: quinn.anya This programming challenge is from an...</small></li>
<li><a href='http://kirkhings.com/code/c/math-tutor-enhanced/417/' rel='bookmark' title='Permanent Link: Math Tutor Enhanced'>Math Tutor Enhanced</a> <small> photo credit: foundphotoslj 4.9: This is a modification of...</small></li>
<li><a href='http://kirkhings.com/code/c/box-office-ticket-sales/159/' rel='bookmark' title='Permanent Link: Box Office Ticket Sales'>Box Office Ticket Sales</a> <small> photo credit: © Natalia Balcerska Photography This programming challenge...</small></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://kirkhings.com/code/c/time-calculator/415/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Test Scores and Letter Grade</title>
		<link>http://kirkhings.com/code/c/test-scores-and-letter-grade/413/</link>
		<comments>http://kirkhings.com/code/c/test-scores-and-letter-grade/413/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 04:20:49 +0000</pubDate>
		<dc:creator>Kirk</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[academic challenge]]></category>

		<guid isPermaLink="false">http://kirkhings.com/?p=413</guid>
		<description><![CDATA[ photo credit: quinn.anya
This programming challenge is from an initial C++ programming course I took in Fall 2007. The Chapter (4) was titled &#8220;Making Decisions&#8221;.
I post these old academic challenges for a few reasons. One is to demonstrate my programming learning, experience, and progression. Another reason is to make sure my code and solutions are [...]


Related posts:<ul><li><a href='http://kirkhings.com/code/c/test-average/156/' rel='bookmark' title='Permanent Link: Test Average'>Test Average</a> <small> photo credit: ccarlstead This programming challenge is from an...</small></li>
<li><a href='http://kirkhings.com/code/c/average-rainfall/139/' rel='bookmark' title='Permanent Link: Average Rainfall'>Average Rainfall</a> <small> photo credit: quapan This programming challenge is from an...</small></li>
<li><a href='http://kirkhings.com/code/c/average-of-values/90/' rel='bookmark' title='Permanent Link: Average of Values'>Average of Values</a> <small> photo credit: psd This programming challenge is from an...</small></li>
<li><a href='http://kirkhings.com/code/c/interest-earned/341/' rel='bookmark' title='Permanent Link: Interest Earned'>Interest Earned</a> <small> photo credit: conorwithonen This programming challenge is from an...</small></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="borrowedPic"><a href="http://www.flickr.com/photos/53326337@N00/3592746676/" title="Discussion of grades" target="_blank"><img src="http://farm4.static.flickr.com/3652/3592746676_fa5ac8852d.jpg" alt="Discussion of grades" border="0" /></a><br /><small><a href="http://creativecommons.org/licenses/by-sa/2.0/" title="Attribution-ShareAlike License" target="_blank"><img src="http://kirkhings.com/wp-content/plugins/photo-dropper/images/cc.png" alt="Creative Commons License" border="0" width="16" height="16" align="absmiddle" /></a> <a href="http://www.photodropper.com/photos/" target="_blank">photo</a> credit: <a href="http://www.flickr.com/photos/53326337@N00/3592746676/" title="quinn.anya" target="_blank">quinn.anya</a></small></div>
<p>This programming challenge is from an initial C++ programming course I took in Fall 2007. The Chapter (4) was titled &#8220;Making Decisions&#8221;.</p>
<p>I post these old academic challenges for a few reasons. One is to demonstrate my programming learning, experience, and progression. Another reason is to make sure my code and solutions are indexed by search engines, so that other beginning programmers may get help if they need it.</p>
<blockquote><p>4.5: Test Scores and Letter Grade:<br />
Write a program that has variables to hold three test scores. The program should ask the user to enter three test scores and then assign the values entered to the variables. The program should display the average of the test scores and the letter grade that is assigned for the test score average. Use the following grade scheme: 90 or greater = A, 80-89 = B, 70-79 = C, 60-69 = D, Below 60 = F. Assume valid user inputs.
</p></blockquote>
<p>My solution:</p>
<pre class="brush: cpp;">
/* Chapter 4 Challenge 5
   Written by Kirk Hingsberger
   October 2, 2007
   Test scroes and grade
*/

#include &lt;iostream&gt;
using namespace std;

int main()
{
  float test1, test2, test3, avg;

  cout &lt;&lt; &quot;Please enter your three test scores each separated by a space.\n&quot;;
  cin &gt;&gt; test1 &gt;&gt; test2 &gt;&gt; test3;

  avg = (test1 + test2 + test3) / 3;

  cout &lt;&lt; &quot;Your test average &quot; &lt;&lt; avg &lt;&lt; &quot; earned you an &quot;;

  if (avg &gt; 90)
    {
      cout &lt;&lt; &quot;A.&quot; &lt;&lt; endl;
    }
  else if (avg &gt; 80)
    {
      cout &lt;&lt; &quot;B.&quot; &lt;&lt; endl;
    }
  else if (avg &gt; 70)
    {
      cout &lt;&lt; &quot;C.&quot; &lt;&lt; endl;
    }
  else if (avg &gt; 60)
    {
      cout &lt;&lt; &quot;D.&quot; &lt;&lt; endl;
    }
  else
    {
      cout &lt;&lt; &quot;F.&quot; &lt;&lt; endl;
    }

  return 0;
}
</pre>
<p>Here is the capture script I turned in for grading:</p>
<pre class="brush: cpp;">
Script started on Tue 02 Oct 2007 11:21:02 AM MDT
$ cat chap4chlg5.cc
/* Chapter 4 Challenge 5
   Written by Kirk Hingsberger
   October 2, 2007
   Test scroes and grade
*/

#include &lt;iostream&gt;
using namespace std;

int main()
{
  float test1, test2, test3, avg;

  cout &lt;&lt; &quot;Please enter your three test scores each separated by a space.\n&quot;;
  cin &gt;&gt; test1 &gt;&gt; test2 &gt;&gt; test3;

  avg = (test1 + test2 + test3) / 3;

  cout &lt;&lt; &quot;Your test average &quot; &lt;&lt; avg &lt;&lt; &quot; earned you &quot;;

  if (avg &gt; 90)
    {
      cout &lt;&lt; &quot;an A.&quot; &lt;&lt; endl;
    }
  else if (avg &gt; 80)
    {
      cout &lt;&lt; &quot;a B.&quot; &lt;&lt; endl;
    }
  else if (avg &gt; 70)
    {
      cout &lt;&lt; &quot;a C.&quot; &lt;&lt; endl;
    }
  else if (avg &gt; 60)
    {
      cout &lt;&lt; &quot;a D.&quot; &lt;&lt; endl;
    }
  else
    {
      cout &lt;&lt; &quot;an F.&quot; &lt;&lt; endl;
    }

  return 0;
}
$ g++ -o chap4chlg5 chap4chlg5.cc -s
$ chap4chlg5
Please enter your three test scores each separated by a space.
44.5 84.5 99.9
Your test average 76.3 earned you a C.
$ exit
exit

Script done on Tue 02 Oct 2007 11:21:41 AM MDT
</pre>


<p>Related posts:<ul><li><a href='http://kirkhings.com/code/c/test-average/156/' rel='bookmark' title='Permanent Link: Test Average'>Test Average</a> <small> photo credit: ccarlstead This programming challenge is from an...</small></li>
<li><a href='http://kirkhings.com/code/c/average-rainfall/139/' rel='bookmark' title='Permanent Link: Average Rainfall'>Average Rainfall</a> <small> photo credit: quapan This programming challenge is from an...</small></li>
<li><a href='http://kirkhings.com/code/c/average-of-values/90/' rel='bookmark' title='Permanent Link: Average of Values'>Average of Values</a> <small> photo credit: psd This programming challenge is from an...</small></li>
<li><a href='http://kirkhings.com/code/c/interest-earned/341/' rel='bookmark' title='Permanent Link: Interest Earned'>Interest Earned</a> <small> photo credit: conorwithonen This programming challenge is from an...</small></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://kirkhings.com/code/c/test-scores-and-letter-grade/413/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Area of Rectangles</title>
		<link>http://kirkhings.com/code/c/area-of-rectangles/411/</link>
		<comments>http://kirkhings.com/code/c/area-of-rectangles/411/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 02:32:57 +0000</pubDate>
		<dc:creator>Kirk</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[academic challenge]]></category>

		<guid isPermaLink="false">http://kirkhings.com/?p=411</guid>
		<description><![CDATA[ photo credit: shaire productions
This programming challenge is from an initial C++ programming course I took in Fall 2007. The Chapter (4) was titled &#8220;Making Decisions&#8221;.
I post these old academic challenges for a few reasons. One is to demonstrate my programming learning, experience, and progression. Another reason is to make sure my code and solutions [...]


Related posts:<ul><li><a href='http://kirkhings.com/code/c/average-rainfall/139/' rel='bookmark' title='Permanent Link: Average Rainfall'>Average Rainfall</a> <small> photo credit: quapan This programming challenge is from an...</small></li>
<li><a href='http://kirkhings.com/code/c/pizza-pi/153/' rel='bookmark' title='Permanent Link: Pizza Pi'>Pizza Pi</a> <small> photo credit: callme_crochet This programming challenge is from an...</small></li>
<li><a href='http://kirkhings.com/code/c/time-calculator/415/' rel='bookmark' title='Permanent Link: Time Calculator'>Time Calculator</a> <small> photo credit: FABIOLA MEDEIROS- direção de arte This programming...</small></li>
<li><a href='http://kirkhings.com/code/c/interest-earned/341/' rel='bookmark' title='Permanent Link: Interest Earned'>Interest Earned</a> <small> photo credit: conorwithonen This programming challenge is from an...</small></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="borrowedPic"><a href="http://www.flickr.com/photos/9822107@N08/2590014845/" title="Swirly Tiles 02" target="_blank"><img src="http://farm4.static.flickr.com/3289/2590014845_1a8a3a93eb.jpg" alt="Swirly Tiles 02" border="0" /></a><br /><small><a href="http://creativecommons.org/licenses/by/2.0/" title="Attribution License" target="_blank"><img src="http://kirkhings.com/wp-content/plugins/photo-dropper/images/cc.png" alt="Creative Commons License" border="0" width="16" height="16" align="absmiddle" /></a> <a href="http://www.photodropper.com/photos/" target="_blank">photo</a> credit: <a href="http://www.flickr.com/photos/9822107@N08/2590014845/" title="shaire productions" target="_blank">shaire productions</a></small></div>
<p>This programming challenge is from an initial C++ programming course I took in Fall 2007. The Chapter (4) was titled &#8220;Making Decisions&#8221;.</p>
<p>I post these old academic challenges for a few reasons. One is to demonstrate my programming learning, experience, and progression. Another reason is to make sure my code and solutions are indexed by search engines, so that other beginning programmers may get help if they need it.</p>
<blockquote><p>4.4: Area of Rectangles: The area of a rectangle is the rectangle&#8217;s length times its width. Write a program that asks for the length and width of two rectangles. The program should tell the user which rectangle has the greater area, or if the areas are the same.
</p></blockquote>
<p>My solution:</p>
<pre class="brush: cpp;">
/* Chapter 4 Challenge 4
   Written by Kirk Hingsberger
   October 2, 2007
   Comparing rectangle areas
*/

#include &lt;iostream&gt;
using namespace std;

int main()
{
  float width1, width2, length1, length2, rect1, rect2;

  cout &lt;&lt; &quot;Enter inches width of first rectangle: &quot;;
  cin &gt;&gt; width1;
  cout &lt;&lt; &quot;Enter inches length of first rectangle: &quot;;
  cin &gt;&gt; length1;
  cout &lt;&lt; &quot;Enter inches width of second rectangle: &quot;;
  cin &gt;&gt; width2;
  cout &lt;&lt; &quot;Enter inches length of second rectangle: &quot;;
  cin &gt;&gt; length2;

  rect1 = width1 * length1;
  rect2 = width2 * length2;

  if (rect1 &gt; rect2)
    {
      cout &lt;&lt; &quot;Rectangle 1 (&quot; &lt;&lt; rect1 &lt;&lt; &quot;) is &quot; &lt;&lt; rect1 - rect2
	   &lt;&lt; &quot; area inches larger than rectangle 2 (&quot;
	   &lt;&lt; rect2 &lt;&lt; &quot;).&quot; &lt;&lt; endl;
    }
  else if (rect1 &lt; rect2)
    {
      cout &lt;&lt; &quot;Rectangle 2 (&quot; &lt;&lt; rect2 &lt;&lt; &quot;) is &quot; &lt;&lt; rect2 - rect1
	   &lt;&lt; &quot; area inches larger than rectangle 1 (&quot;
	   &lt;&lt; rect1 &lt;&lt; &quot;).&quot; &lt;&lt; endl;
    }
  else if (rect1 == rect2)
    {
      cout &lt;&lt; &quot;Rectangles 1 and 2 are equal at &quot;
	   &lt;&lt; rect1 &lt;&lt; &quot; area inches.&quot; &lt;&lt; endl;
    }

  return 0;
}
</pre>
<p>Here is the capture script I turned in for grading:</p>
<pre class="brush: cpp;">
Script started on Tue 02 Oct 2007 10:49:54 AM MDT
$ cat chap4chlg4.cc
/* Chapter 4 Challenge 4
   Written by Kirk Hingsberger
   October 2, 2007
   Comparing rectangle areas
*/

#include &lt;iostream&gt;
using namespace std;

int main()
{
  float width1, width2, length1, length2, rect1, rect2;

  cout &lt;&lt; &quot;Enter inches width of first rectangle: &quot;;
  cin &gt;&gt; width1;
  cout &lt;&lt; &quot;Enter inches length of first rectangle: &quot;;
  cin &gt;&gt; length1;
  cout &lt;&lt; &quot;Enter inches width of second rectangle: &quot;;
  cin &gt;&gt; width2;
  cout &lt;&lt; &quot;Enter inches length of second rectangle: &quot;;
  cin &gt;&gt; length2;

  rect1 = width1 * length1;
  rect2 = width2 * length2;

  if (rect1 &gt; rect2)
    {
      cout &lt;&lt; &quot;Rectangle 1 (&quot; &lt;&lt; rect1 &lt;&lt; &quot;) is &quot; &lt;&lt; rect1 - rect2
	   &lt;&lt; &quot; area inches larger than rectangle 2 (&quot;
	   &lt;&lt; rect2 &lt;&lt; &quot;).&quot; &lt;&lt; endl;
    }
  else if (rect1 &lt; rect2)
    {
      cout &lt;&lt; &quot;Rectangle 2 (&quot; &lt;&lt; rect2 &lt;&lt; &quot;) is &quot; &lt;&lt; rect2 - rect1
	   &lt;&lt; &quot; area inches larger than rectangle 1 (&quot;
	   &lt;&lt; rect1 &lt;&lt; &quot;).&quot; &lt;&lt; endl;
    }
  else if (rect1 == rect2)
    {
      cout &lt;&lt; &quot;Rectangles 1 and 2 are equal at &quot;
	   &lt;&lt; rect1 &lt;&lt; &quot; area inches.&quot; &lt;&lt; endl;
    }

  return 0;
}
$ g++ -o chap4chlg4 chapr4chlg4.cc -s
$ chap4chlg4
Enter inches width of first rectangle: 2
Enter inches length of first rectangle: 3
Enter inches width of second rectangle: 3
Enter inches length of second rectangle: 4
Rectangle 2 (12) is 6 area inches larger than rectangle 1 (6).
$ chap4chlg4
Enter inches width of first rectangle: 4
Enter inches length of first rectangle: 3
Enter inches width of second rectangle: 3
Enter inches length of second rectangle: 2
Rectangle 1 (12) is 6 area inches larger than rectangle 2 (6).
$ chap4chlg4
Enter inches width of first rectangle: 2
Enter inches length of first rectangle: 3
Enter inches width of second rectangle: 2
Enter inches length of second rectangle: 3
Rectangles 1 and 2 are equal at 6 area inches.
$ exit
exit

Script done on Tue 02 Oct 2007 10:50:40 AM MDT
</pre>


<p>Related posts:<ul><li><a href='http://kirkhings.com/code/c/average-rainfall/139/' rel='bookmark' title='Permanent Link: Average Rainfall'>Average Rainfall</a> <small> photo credit: quapan This programming challenge is from an...</small></li>
<li><a href='http://kirkhings.com/code/c/pizza-pi/153/' rel='bookmark' title='Permanent Link: Pizza Pi'>Pizza Pi</a> <small> photo credit: callme_crochet This programming challenge is from an...</small></li>
<li><a href='http://kirkhings.com/code/c/time-calculator/415/' rel='bookmark' title='Permanent Link: Time Calculator'>Time Calculator</a> <small> photo credit: FABIOLA MEDEIROS- direção de arte This programming...</small></li>
<li><a href='http://kirkhings.com/code/c/interest-earned/341/' rel='bookmark' title='Permanent Link: Interest Earned'>Interest Earned</a> <small> photo credit: conorwithonen This programming challenge is from an...</small></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://kirkhings.com/code/c/area-of-rectangles/411/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Random Image Display with JavaScript</title>
		<link>http://kirkhings.com/code/javascript/random-image-display-with-javascript/406/</link>
		<comments>http://kirkhings.com/code/javascript/random-image-display-with-javascript/406/#comments</comments>
		<pubDate>Mon, 25 May 2009 03:27:24 +0000</pubDate>
		<dc:creator>Kirk</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[lynda]]></category>
		<category><![CDATA[self-instructional challenge]]></category>

		<guid isPermaLink="false">http://kirkhings.com/?p=406</guid>
		<description><![CDATA[ photo credit: davidChief
This programming challenge is from a Lynda.com instructional video, featuring Dori Smith, which I studied/practiced last summer but once again spring 2009. I do not mean to just re-post the wonderful Lynda.com code, but rather add instructional value to it by way of clearer variable names and explanatory comments. The end result [...]


Related posts:<ul><li><a href='http://kirkhings.com/code/javascript/random-bingo-card-generator-with-ajax-reset/224/' rel='bookmark' title='Permanent Link: Random BINGO Card Generator with Ajax Reset'>Random BINGO Card Generator with Ajax Reset</a> <small> photo credit: Keees This programming challenge is from a...</small></li>
<li><a href='http://kirkhings.com/code/javascript/simple-and-improved-image-rollovers/298/' rel='bookmark' title='Permanent Link: Simple and Improved Image Rollovers'>Simple and Improved Image Rollovers</a> <small> photo credit: Etwood This programming challenge is from a...</small></li>
<li><a href='http://kirkhings.com/code/javascript/slideshow-from-images-array/380/' rel='bookmark' title='Permanent Link: Slideshow from Images Array'>Slideshow from Images Array</a> <small> photo credit: pawpaw67 This programming challenge is from a...</small></li>
<li><a href='http://kirkhings.com/code/javascript/three-state-javascript-rollover/312/' rel='bookmark' title='Permanent Link: Three-State JavaScript Rollover'>Three-State JavaScript Rollover</a> <small> photo credit: chimothy27 This programming challenge is from a...</small></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="borrowedPic"><a href="http://www.flickr.com/photos/35395389@N00/516645478/" title="Awkward glance" target="_blank"><img src="http://farm1.static.flickr.com/232/516645478_0f73bb7bc8.jpg" alt="Awkward glance" border="0" /></a><br /><small><a href="http://creativecommons.org/licenses/by/2.0/" title="Attribution License" target="_blank"><img src="http://kirkhings.com/wp-content/plugins/photo-dropper/images/cc.png" alt="Creative Commons License" border="0" width="16" height="16" align="absmiddle" /></a> <a href="http://www.photodropper.com/photos/" target="_blank">photo</a> credit: <a href="http://www.flickr.com/photos/35395389@N00/516645478/" title="davidChief" target="_blank">davidChief</a></small></div>
<p>This programming challenge is from a Lynda.com instructional video, featuring Dori Smith, which I studied/practiced last summer but once again spring 2009. I do not mean to just re-post the wonderful Lynda.com code, but rather add instructional value to it by way of clearer variable names and explanatory comments. The end result itself is not terribly sexy, but I liked the algorithm construction process.</p>
<p>I post these self-instructional challenges for a few reasons. One is to demonstrate my programming learning, experience, and progression. Another reason is to make sure my code and solutions are indexed by search engines, so that other beginning programmers may get help if they need it. Finally, self-instructional challenges are interesting and different than academic challenges because I sought, discovered, and performed them on my own volition without anyone else telling me to do so. I did it because I wanted to learn and practice.</p>
<blockquote><p>Challenge: Create a simple script to randomly pull and display an image on a web page.
</p></blockquote>
<p>The HTML solution:</p>
<pre class="brush: xml;">
&lt;html&gt;
&lt;head&gt;
	&lt;title&gt;NASA Astronomy Picture of the Day Gallery&lt;/title&gt;
	&lt;script type=&quot;text/javascript&quot; src=&quot;script.js&quot;&gt;&lt;/script&gt;
	&lt;link rel=&quot;stylesheet&quot; rev=&quot;stylesheet&quot; href=&quot;styles.css&quot; /&gt;
&lt;/head&gt;
&lt;body&gt;
	&lt;img src=&quot;images/spacer.gif&quot; id=&quot;aRandomPicture&quot; alt=&quot;a Random image&quot; /&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>The JavaScript solution:</p>
<pre class="brush: jscript;">
// run randomPic function whenever page loads
window.onload = randomPic;

// setup array of image files
var myPics = new Array(&quot;images/1.jpg&quot;, &quot;images/2.jpg&quot;, &quot;images/3.jpg&quot;, &quot;images/4.jpg&quot;, &quot;images/5.jpg&quot;, &quot;images/6.jpg&quot;, &quot;images/7.jpg&quot;, &quot;images8.jpg&quot;);

function randomPic() {
	// generate random number based on image quantity
	randomNumber = Math.floor((Math.random() * myPics.length));
	// set the image src attribute to a random pic in the image array
	document.getElementById(&quot;aRandomPicture&quot;).src = myPics[randomNumber];
}
</pre>
<p>It&#8217;s as simple as that!</p>


<p>Related posts:<ul><li><a href='http://kirkhings.com/code/javascript/random-bingo-card-generator-with-ajax-reset/224/' rel='bookmark' title='Permanent Link: Random BINGO Card Generator with Ajax Reset'>Random BINGO Card Generator with Ajax Reset</a> <small> photo credit: Keees This programming challenge is from a...</small></li>
<li><a href='http://kirkhings.com/code/javascript/simple-and-improved-image-rollovers/298/' rel='bookmark' title='Permanent Link: Simple and Improved Image Rollovers'>Simple and Improved Image Rollovers</a> <small> photo credit: Etwood This programming challenge is from a...</small></li>
<li><a href='http://kirkhings.com/code/javascript/slideshow-from-images-array/380/' rel='bookmark' title='Permanent Link: Slideshow from Images Array'>Slideshow from Images Array</a> <small> photo credit: pawpaw67 This programming challenge is from a...</small></li>
<li><a href='http://kirkhings.com/code/javascript/three-state-javascript-rollover/312/' rel='bookmark' title='Permanent Link: Three-State JavaScript Rollover'>Three-State JavaScript Rollover</a> <small> photo credit: chimothy27 This programming challenge is from a...</small></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://kirkhings.com/code/javascript/random-image-display-with-javascript/406/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Count CSS Specificity Scores and Leverage !Important Overrides</title>
		<link>http://kirkhings.com/code/css/how-to-count-css-specificity-scores-and-leverage-important-overrides/401/</link>
		<comments>http://kirkhings.com/code/css/how-to-count-css-specificity-scores-and-leverage-important-overrides/401/#comments</comments>
		<pubDate>Mon, 25 May 2009 00:43:09 +0000</pubDate>
		<dc:creator>Kirk</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[concept]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[element]]></category>
		<category><![CDATA[id]]></category>
		<category><![CDATA[inline]]></category>
		<category><![CDATA[selector]]></category>

		<guid isPermaLink="false">http://kirkhings.com/?p=401</guid>
		<description><![CDATA[ photo credit: laffy4k
If you are having difficulty getting a particular CSS style to &#8220;appear&#8221;, one thing to check is your specificity. CSS specificity is a four digit score for resolving cascade conflicts. You can actually add up the specificity score to determine which conflicting style should prevail. The four digit score is comprised of [...]


Related posts:<ul><li><a href='http://kirkhings.com/code/css/space-critical-css-selectors/65/' rel='bookmark' title='Permanent Link: Space is Critical in CSS Selectors'>Space is Critical in CSS Selectors</a> <small> photo credit: makelessnoise If you are having difficulty getting...</small></li>
<li><a href='http://kirkhings.com/code/c/test-scores-and-letter-grade/413/' rel='bookmark' title='Permanent Link: Test Scores and Letter Grade'>Test Scores and Letter Grade</a> <small> photo credit: quinn.anya This programming challenge is from an...</small></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="borrowedPic"><a href="http://www.flickr.com/photos/73207064@N00/173579871/" title="Score Kept Here" target="_blank"><img src="http://farm1.static.flickr.com/45/173579871_4cae652b36.jpg" alt="Score Kept Here" border="0" /></a><br /><small><a href="http://creativecommons.org/licenses/by/2.0/" title="Attribution License" target="_blank"><img src="http://kirkhings.com/wp-content/plugins/photo-dropper/images/cc.png" alt="Creative Commons License" border="0" width="16" height="16" align="absmiddle" /></a> <a href="http://www.photodropper.com/photos/" target="_blank">photo</a> credit: <a href="http://www.flickr.com/photos/73207064@N00/173579871/" title="laffy4k" target="_blank">laffy4k</a></small></div>
<p>If you are having difficulty getting a particular CSS style to &#8220;appear&#8221;, one thing to check is your specificity. CSS specificity is a four digit score for resolving cascade conflicts. You can actually add up the specificity score to determine which conflicting style should prevail. The four digit score is comprised of inline style, id, class, and element. You can express it as #, #, #, #. Examples are provided below.</p>
<p>For example, what gets displayed when you have two conflicting styles specified for the same element?</p>
<pre class="brush: css;">
li { background-color: blue; }
li { background-color: yellow; }
</pre>
<p>Of course we know intuitively and through practice that the second style is displayed because it is read after the first and so it &#8220;overwrites&#8221; that first style. Less intuitively, you should know that the second wins because it has the same level of specificity as that first style. The two styles above each have the score 0, 0, 0, 1 because they are not inline styles, they have no id or class specification, and they specify only one element each.</p>
<p>Specificity refers to how specific you identify an element. Referring to just &#8216;li&#8217; is just the single list item element, you are not referring to additional element information. This is like specifying different styles based on nesting, such as &#8216;div a&#8217; vs. &#8216;p a&#8217;. Those could have two different styles because they have different nesting.</p>
<p>For another example, which style do you think will get displayed?</p>
<pre class="brush: css;">
ul li { background-color: blue; }
li { background-color: yellow; }
</pre>
<p>The first style will win over the second because of greater element specificity, despite the potential of overwriting later in the script. The first style&#8217;s specificity score is 0, 0, 0, 2 while the second style&#8217;s score is still just 0, 0, 0, 1. That tiny extra specificity causes the first style to win out and get displayed. Now the power of specificity should be dawning on you, and why specificity can cause frustrating display problems in a large stylesheet. Let&#8217;s explore further. </p>
<p>Which style do you think will get displayed?</p>
<pre class="brush: css;">
.nav li { background-color: blue; }
ul li { background-color: yellow; }
</pre>
<p>Of course the first style wins again because the class selector has greater specificity than the element selectors. The score is 0, 0, 1, 1, versus 0, 0, 0, 2.</p>
<p>Which style do you think will get displayed?</p>
<pre class="brush: css;">
#nav li { background-color: blue; }
.nav ul li { background-color: yellow; }
</pre>
<p>Of course the first style wins again because the id selector has greater specificity than the class selector. The score is 0, 1, 0, 1, versus 0, 0, 1, 2.</p>
<p>Which style do you think will get displayed?</p>
<pre class="brush: css;">
#nav .nav div ul li { background-color: yellow; }
...
&lt;body&gt;
&lt;div id=&quot;nav&quot;&gt;&lt;ul&gt;&lt;li style=&quot;background-color: blue;&quot;&gt;Data&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/body&gt;
</pre>
<p>The inline style gets displayed here (though only on the elements containing the inline style) because inline styles have slightly higher specificity than id, class, or element styles specified in header styles or external stylesheets (remember &#8216;cascading&#8217; is a key concept). The score is 1, 0, 0, 0 versus 0, 1, 1, 3. Although the specificity is greater here, you realize inline styles are an evil thing because you are mixing style with content. You should know the rule exists and how it works, and then pledge to never take it that far unless you are debugging code. </p>
<p>Speaking of debugging code, what if you specify something as much as you reasonably can, yet you cannot get it to display? Rather than dropping it into an inline style, you can use the !important keyword in your style, which functions as a kind of override function as far as specificity goes. </p>
<p>Which style do you think will get displayed?</p>
<pre class="brush: css;">
#nav .nav div ul li { background-color: blue !important; }
#nav .nav div ul li { background-color: yellow; }
</pre>
<p>Of course the first style wins again because of the !important keyword (yes, it will also beat an inline style specification). This case indicates you have conflicting styles in your stylesheet and you need to check specificity to target what is conflicting. If your style does not display when you use !important, it indicates you have another problem like misspelling an element, class, or id. </p>
<p>After you have fixed the conflict, go back and remove the !important keyword or you will forever be chasing your tail across stylesheets with more and more !important declarations. Use !important only for debugging purposes. </p>
<p>Finally, remember specificity only comes into play when styles conflict. You can have dozens of separate style statements work beautifully together so long as they are specifying different style elements (such as background-color, font-style, color, padding, etc.) It is only when they specify the same style elements with conflicting values does the specificity score become important.</p>


<p>Related posts:<ul><li><a href='http://kirkhings.com/code/css/space-critical-css-selectors/65/' rel='bookmark' title='Permanent Link: Space is Critical in CSS Selectors'>Space is Critical in CSS Selectors</a> <small> photo credit: makelessnoise If you are having difficulty getting...</small></li>
<li><a href='http://kirkhings.com/code/c/test-scores-and-letter-grade/413/' rel='bookmark' title='Permanent Link: Test Scores and Letter Grade'>Test Scores and Letter Grade</a> <small> photo credit: quinn.anya This programming challenge is from an...</small></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://kirkhings.com/code/css/how-to-count-css-specificity-scores-and-leverage-important-overrides/401/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bottles of Beer Song via Java</title>
		<link>http://kirkhings.com/code/java/bottles-of-beer-song-via-java/388/</link>
		<comments>http://kirkhings.com/code/java/bottles-of-beer-song-via-java/388/#comments</comments>
		<pubDate>Sun, 24 May 2009 19:42:03 +0000</pubDate>
		<dc:creator>Kirk</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[head first java]]></category>
		<category><![CDATA[self-instructional challenge]]></category>

		<guid isPermaLink="false">http://kirkhings.com/?p=388</guid>
		<description><![CDATA[ photo credit: NUCO
This programming challenge is from the Head First Java book, which I studied and practiced spring 2009. The end result itself is not terribly sexy, but I liked the algorithm construction process. My programming curriculum changed course during the first year, and they eliminated our Java classes. I was still curious about [...]


Related posts:<ul><li><a href='http://kirkhings.com/code/java/phrase-o-matic-consultant-wisdom-via-java/419/' rel='bookmark' title='Permanent Link: Phrase-O-Matic Consultant Wisdom via Java'>Phrase-O-Matic Consultant Wisdom via Java</a> <small> photo credit: schedetzki Challenge: Create three lists of buzzwords...</small></li>
<li><a href='http://kirkhings.com/code/java/plain-and-recursive-factorials-with-full-print-enhancements/239/' rel='bookmark' title='Permanent Link: Plain and Recursive Factorials with Full Print Enhancements'>Plain and Recursive Factorials with Full Print Enhancements</a> <small> photo credit: gadl This programming challenge is from a...</small></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="borrowedPic"><a href="http://www.flickr.com/photos/89046340@N00/107340991/" title="PA300108" target="_blank"><img src="http://farm1.static.flickr.com/51/107340991_b1bda6f04d.jpg" alt="PA300108" border="0" /></a><br /><small><a href="http://creativecommons.org/licenses/by/2.0/" title="Attribution License" target="_blank"><img src="http://kirkhings.com/wp-content/plugins/photo-dropper/images/cc.png" alt="Creative Commons License" border="0" width="16" height="16" align="absmiddle" /></a> <a href="http://www.photodropper.com/photos/" target="_blank">photo</a> credit: <a href="http://www.flickr.com/photos/89046340@N00/107340991/" title="NUCO" target="_blank">NUCO</a></small></div>
<p>This programming challenge is from the Head First Java book, which I studied and practiced spring 2009. The end result itself is not terribly sexy, but I liked the algorithm construction process. My programming curriculum changed course during the first year, and they eliminated our Java classes. I was still curious about Java, so I took it upon myself to self-learn Java. This was one of my first products.</p>
<p>I post these self-instructional challenges for a few reasons. One is to demonstrate my programming learning, experience, and progression. Another reason is to make sure my code and solutions are indexed by search engines, so that other beginning programmers may get help if they need it. Finally, self-instructional challenges are interesting and different than academic challenges because I sought, discovered, and performed them on my own volition without anyone else telling me to do so. I did it because I wanted to learn and practice.</p>
<blockquote><p>Challenge: Create a simple program which outputs the classic &#8220;99 Bottles of Beer&#8221; song, counting down from 99 to 0 bottles. In addition to outputting the correct number of bottles in each chorus, output the correct plural or singular form of &#8220;bottle&#8221; where appropriate to the number remaining. When there are no more bottles left then state final line.
</p></blockquote>
<p>My solution:</p>
<pre class="brush: java;">
package bottlesofbeer;

/**
 *
 * @author kirk
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // initialize starting number of bottles on wall
        int beerNum = 99;

        // initialize plural form of bottle used most often
        String word = &quot;bottles&quot;;

        while (beerNum &gt; 0) {
            // if only 1 bottle is left then change to singular form
            if (beerNum == 1) { word = &quot;bottle&quot;; }

            // output song chorus using current variable states
            System.out.println(beerNum + &quot; &quot; + word + &quot; of beer on the wall,&quot;);
            System.out.println(beerNum + &quot; &quot; + word + &quot; of beer!&quot;);
            System.out.println(&quot;Take one down, pass it around.&quot;);

            // decrement beerNum cuz we took one down and passed it around
            beerNum--;
            if (beerNum == 1) { word = &quot;bottle&quot;; }

            // so long as there are still bottles on the wall
            if (beerNum &gt; 0) {
                System.out.println(beerNum + &quot; &quot; + word + &quot; of beer on the wall!&quot;);
                System.out.println();
            }
            // when there are no more bottles on the wall
            else {
                System.out.println(&quot;No more bottles of beer on the wall!&quot;);
            } // ends if/else
        } // ends while loop
    } // ends main method
} // ends class
</pre>
<p>Here is the output:</p>
<div id="attachment_394" class="wp-caption alignleft" style="width: 310px"><img src="http://kirkhings.com/wp-content/uploads/beersong-java.png" alt="99 Bottles of Beer Song output via Java" title="beersong-java" width="300" height="454" class="size-full wp-image-394" /><p class="wp-caption-text">99 Bottles of Beer Song output via Java</p></div>


<p>Related posts:<ul><li><a href='http://kirkhings.com/code/java/phrase-o-matic-consultant-wisdom-via-java/419/' rel='bookmark' title='Permanent Link: Phrase-O-Matic Consultant Wisdom via Java'>Phrase-O-Matic Consultant Wisdom via Java</a> <small> photo credit: schedetzki Challenge: Create three lists of buzzwords...</small></li>
<li><a href='http://kirkhings.com/code/java/plain-and-recursive-factorials-with-full-print-enhancements/239/' rel='bookmark' title='Permanent Link: Plain and Recursive Factorials with Full Print Enhancements'>Plain and Recursive Factorials with Full Print Enhancements</a> <small> photo credit: gadl This programming challenge is from a...</small></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://kirkhings.com/code/java/bottles-of-beer-song-via-java/388/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Slideshow from Images Array</title>
		<link>http://kirkhings.com/code/javascript/slideshow-from-images-array/380/</link>
		<comments>http://kirkhings.com/code/javascript/slideshow-from-images-array/380/#comments</comments>
		<pubDate>Fri, 15 May 2009 19:57:23 +0000</pubDate>
		<dc:creator>Kirk</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[lynda]]></category>
		<category><![CDATA[self-instructional challenge]]></category>

		<guid isPermaLink="false">http://kirkhings.com/?p=380</guid>
		<description><![CDATA[ photo credit: pawpaw67
This programming challenge is from a Lynda.com instructional video, featuring Dori Smith, which I studied/practiced last summer but once again spring 2009. I do not mean to just re-post the wonderful Lynda.com code, but rather add instructional value to it by way of clearer variable names and explanatory comments. The end result [...]


Related posts:<ul><li><a href='http://kirkhings.com/code/javascript/random-image-display-with-javascript/406/' rel='bookmark' title='Permanent Link: Random Image Display with JavaScript'>Random Image Display with JavaScript</a> <small> photo credit: davidChief This programming challenge is from a...</small></li>
<li><a href='http://kirkhings.com/code/javascript/three-state-javascript-rollover/312/' rel='bookmark' title='Permanent Link: Three-State JavaScript Rollover'>Three-State JavaScript Rollover</a> <small> photo credit: chimothy27 This programming challenge is from a...</small></li>
<li><a href='http://kirkhings.com/code/javascript/accessible-javascript-rollover-with-three-state-functionality/319/' rel='bookmark' title='Permanent Link: Accessible JavaScript Rollover with Three-State Functionality'>Accessible JavaScript Rollover with Three-State Functionality</a> <small> photo credit: Rhian vK This programming challenge is from...</small></li>
<li><a href='http://kirkhings.com/code/javascript/simple-and-improved-image-rollovers/298/' rel='bookmark' title='Permanent Link: Simple and Improved Image Rollovers'>Simple and Improved Image Rollovers</a> <small> photo credit: Etwood This programming challenge is from a...</small></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="borrowedPic"><a href="http://www.flickr.com/photos/7641646@N03/1302964167/" title="Thistle Seeds" target="_blank"><img src="http://farm2.static.flickr.com/1007/1302964167_a809f4945f.jpg" alt="Thistle Seeds" border="0" /></a><br /><small><a href="http://creativecommons.org/licenses/by-sa/2.0/" title="Attribution-ShareAlike License" target="_blank"><img src="http://kirkhings.com/wp-content/plugins/photo-dropper/images/cc.png" alt="Creative Commons License" border="0" width="16" height="16" align="absmiddle" /></a> <a href="http://www.photodropper.com/photos/" target="_blank">photo</a> credit: <a href="http://www.flickr.com/photos/7641646@N03/1302964167/" title="pawpaw67" target="_blank">pawpaw67</a></small></div>
<p>This programming challenge is from a Lynda.com instructional video, featuring Dori Smith, which I studied/practiced last summer but once again spring 2009. I do not mean to just re-post the wonderful Lynda.com code, but rather add instructional value to it by way of clearer variable names and explanatory comments. The end result itself is not terribly sexy, but I liked the algorithm construction process.</p>
<p>I post these self-instructional challenges for a few reasons. One is to demonstrate my programming learning, experience, and progression. Another reason is to make sure my code and solutions are indexed by search engines, so that other beginning programmers may get help if they need it. Finally, self-instructional challenges are interesting and different than academic challenges because I sought, discovered, and performed them on my own volition without anyone else telling me to do so. I did it because I wanted to learn and practice.</p>
<blockquote><p>Challenge: Create a JavaScript image slideshow with next and previous links that use an array. Loop the script so the slideshow never reaches an end.
</p></blockquote>
<p>The HTML solution:</p>
<pre class="brush: xml;">
&lt;html&gt;
&lt;head&gt;
	&lt;title&gt;NASA Patches Slideshow&lt;/title&gt;
	&lt;script type=&quot;text/javascript&quot; src=&quot;script.js&quot;&gt;&lt;/script&gt;
	&lt;link rel=&quot;stylesheet&quot; rev=&quot;stylesheet&quot; href=&quot;styles.css&quot; /&gt;
&lt;/head&gt;
&lt;body&gt;
	&lt;div align=&quot;center&quot;&gt;
		&lt;h1&gt;NASA Patches Slideshow&lt;/h1&gt;
		&lt;img src=&quot;images/nasa.jpeg&quot; id=&quot;currentPicture&quot; width=&quot;201&quot; height=&quot;155&quot; alt=&quot;Slideshow&quot; /&gt;
		&lt;h2&gt;
        	&lt;a href=&quot;previous.html&quot; id=&quot;prevLink&quot;&gt;&amp;laquo; Previous&lt;/a&gt;&amp;nbsp;&amp;nbsp;
            &lt;a href=&quot;next.html&quot; id=&quot;nextLink&quot;&gt;Next &amp;raquo;&lt;/a&gt;&lt;/h2&gt;
	&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>The JavaScript solution:</p>
<pre class="brush: jscript;">
window.onload = initLinks;

// create array of pictures/strings
var myPics = new Array(&quot;images/nasa.jpeg&quot;, &quot;images/columbia1.gif&quot;, &quot;images/columbia2.jpeg&quot;, &quot;images/columbia3.jpg&quot;, &quot;images/columbia4.jpeg&quot;, &quot;images/challenger.jpeg&quot;);

// track currently displayed image, set to 0
var thisPic = 0;

// handle behaviors when next and previous links are clicked
function initLinks() {
	// when prevLink is clicked, call function to fetch the previous pic
	document.getElementById(&quot;prevLink&quot;).onclick = processPrevious;
	// when nextLink is clicked, call function to fetch the next pic
	document.getElementById(&quot;nextLink&quot;).onclick = processNext;
}

// called when prevLink is clicked
function processPrevious() {
	// if we are on slide 0
	if (thisPic == 0) {
		// then set thisPic to be same value as array length (meaning last picture)
		// this allows looping around the collection not reaching an end
		thisPic = myPics.length;
	}
	// decrement thisPic to be one less than last pic so as to point to previous
	thisPic--;
	// set source of page's displayed picture to be new current
	document.getElementById(&quot;currentPicture&quot;).src = myPics[thisPic];
	// js handled the work, so prevent next page from being fetched
	return false;
}

// called when nextLink is clicked
function processNext() {
	// incerement thisPic to be one more than last pic so as to point to next
	thisPic++;
	// if we are on last picture in array
	if (thisPic == myPics.length) {
		// then set thisPic to be original value in array (meaning first picture)
		// this allows looping around the collection not reaching an end
		thisPic = 0;
	}
	// set source of page's displayed picture to be new current
	document.getElementById(&quot;currentPicture&quot;).src = myPics[thisPic];
	// js handled the work, so prevent next page from being fetched
	return false;
}
</pre>
<p>Here is a screenshot example of a previous slideshow image:<br />
<div id="attachment_382" class="wp-caption alignleft" style="width: 466px"><img src="http://kirkhings.com/wp-content/uploads/js-nasapatches2.png" alt="Example of the previous image fetched" title="js-nasapatches2" width="456" height="306" class="size-full wp-image-382" /><p class="wp-caption-text">Example of the previous image fetched</p></div></p>
<p>Here is a screenshot example of a next slideshow image:<br />
<div id="attachment_381" class="wp-caption alignleft" style="width: 466px"><img src="http://kirkhings.com/wp-content/uploads/js-nasapatches1.png" alt="Example of the next image fetched" title="js-nasapatches1" width="456" height="306" class="size-full wp-image-381" /><p class="wp-caption-text">Example of the next image fetched</p></div></p>


<p>Related posts:<ul><li><a href='http://kirkhings.com/code/javascript/random-image-display-with-javascript/406/' rel='bookmark' title='Permanent Link: Random Image Display with JavaScript'>Random Image Display with JavaScript</a> <small> photo credit: davidChief This programming challenge is from a...</small></li>
<li><a href='http://kirkhings.com/code/javascript/three-state-javascript-rollover/312/' rel='bookmark' title='Permanent Link: Three-State JavaScript Rollover'>Three-State JavaScript Rollover</a> <small> photo credit: chimothy27 This programming challenge is from a...</small></li>
<li><a href='http://kirkhings.com/code/javascript/accessible-javascript-rollover-with-three-state-functionality/319/' rel='bookmark' title='Permanent Link: Accessible JavaScript Rollover with Three-State Functionality'>Accessible JavaScript Rollover with Three-State Functionality</a> <small> photo credit: Rhian vK This programming challenge is from...</small></li>
<li><a href='http://kirkhings.com/code/javascript/simple-and-improved-image-rollovers/298/' rel='bookmark' title='Permanent Link: Simple and Improved Image Rollovers'>Simple and Improved Image Rollovers</a> <small> photo credit: Etwood This programming challenge is from a...</small></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://kirkhings.com/code/javascript/slideshow-from-images-array/380/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Diner Specials Display</title>
		<link>http://kirkhings.com/code/visual-basic-code/diner-specials-display/375/</link>
		<comments>http://kirkhings.com/code/visual-basic-code/diner-specials-display/375/#comments</comments>
		<pubDate>Fri, 15 May 2009 04:57:44 +0000</pubDate>
		<dc:creator>Kirk</dc:creator>
				<category><![CDATA[Visual Basic]]></category>
		<category><![CDATA[academic challenge]]></category>
		<category><![CDATA[visual basic]]></category>

		<guid isPermaLink="false">http://kirkhings.com/?p=375</guid>
		<description><![CDATA[ photo credit: wEnDaLicious
This programming challenge is from a Visual Basic.Net programming course I took in Spring 2008. The Chapter (1) was titled &#8220;Introduction to Visual Basic .Net 2005&#8243;.
I post these old academic challenges for a few reasons. One is to demonstrate my programming learning, experience, and progression. Another reason is to make sure my [...]


Related posts:<ul><li><a href='http://kirkhings.com/code/visual-basic-code/button-driven-quotes/352/' rel='bookmark' title='Permanent Link: Button-Driven Quotes'>Button-Driven Quotes</a> <small> photo credit: bogenfreund This programming challenge is from a...</small></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="borrowedPic"><a href="http://www.flickr.com/photos/25597828@N00/1066580415/" title="Sandwich @ Tick Tock Diner - 481 8th Ave" target="_blank"><img src="http://farm2.static.flickr.com/1277/1066580415_552e34b1ff.jpg" alt="Sandwich @ Tick Tock Diner - 481 8th Ave" border="0" /></a><br /><small><a href="http://creativecommons.org/licenses/by-nd/2.0/" title="Attribution-NoDerivs License" target="_blank"><img src="http://kirkhings.com/wp-content/plugins/photo-dropper/images/cc.png" alt="Creative Commons License" border="0" width="16" height="16" align="absmiddle" /></a> <a href="http://www.photodropper.com/photos/" target="_blank">photo</a> credit: <a href="http://www.flickr.com/photos/25597828@N00/1066580415/" title="wEnDaLicious" target="_blank">wEnDaLicious</a></small></div>
<p>This programming challenge is from a Visual Basic.Net programming course I took in Spring 2008. The Chapter (1) was titled &#8220;Introduction to Visual Basic .Net 2005&#8243;.</p>
<p>I post these old academic challenges for a few reasons. One is to demonstrate my programming learning, experience, and progression. Another reason is to make sure my code and solutions are indexed by search engines, so that other beginning programmers may get help if they need it.</p>
<blockquote><p>1.5: Create a project to display the daily specials for &#8220;your&#8221; diner. Make up a name for your diner and display it in a label at the top of the form. Add a label to display the appropriate special depending on the button that is pressed. the buttons should be:</p>
<ul>
<li>Soup of the Day</li>
<li>Chef&#8217;s Special</li>
<li>Daily Fish</li>
</ul>
<p>Also include an Exit button.
</p></blockquote>
<p>My solution code:</p>
<pre class="brush: vb;">
' Assignment 1
' Problem 1.5
' Kirk Hingsberger
' Display Menu Specials

Public Class specialsForm
    Private Sub exitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitButton.Click
        ' Exits program
        Me.Close()
    End Sub

    Private Sub soupButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles soupButton.Click
        ' Display Soup of Day
        Me.specialsTextLabel.Text = &quot;Kirk's Diner is offering hot hot water as our soup of the day.&quot;
    End Sub

    Private Sub chefsButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chefsButton.Click
        ' Display Chef's Special
        Me.specialsTextLabel.Text = &quot;Kirk's Diner is offering yesterday's leftovers as our premium chef's special today.&quot;
    End Sub

    Private Sub fishButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles fishButton.Click
        ' Display Daily Fish
        Me.specialsTextLabel.Text = &quot;Kirk's Diner is offering fillet of oscar as today's daily fish special.&quot;
    End Sub
End Class
</pre>
<p>My solution&#8217;s build screenshot:</p>
<div id="attachment_376" class="wp-caption alignleft" style="width: 410px"><img src="http://kirkhings.com/wp-content/uploads/vb1-5.png" alt="Press a button to get a diner special" title="vb1-5" width="400" height="301" class="size-full wp-image-376" /><p class="wp-caption-text">Press a button to get a diner special</p></div>


<p>Related posts:<ul><li><a href='http://kirkhings.com/code/visual-basic-code/button-driven-quotes/352/' rel='bookmark' title='Permanent Link: Button-Driven Quotes'>Button-Driven Quotes</a> <small> photo credit: bogenfreund This programming challenge is from a...</small></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://kirkhings.com/code/visual-basic-code/diner-specials-display/375/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
