<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>guitsaru</title>
	<atom:link href="http://guitsaru.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://guitsaru.wordpress.com</link>
	<description></description>
	<lastBuildDate>Mon, 16 Jun 2008 18:36:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='guitsaru.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>guitsaru</title>
		<link>http://guitsaru.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://guitsaru.wordpress.com/osd.xml" title="guitsaru" />
	<atom:link rel='hub' href='http://guitsaru.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Break Strings into Separate Lines</title>
		<link>http://guitsaru.wordpress.com/2008/06/16/break-strings-into-separate-lines/</link>
		<comments>http://guitsaru.wordpress.com/2008/06/16/break-strings-into-separate-lines/#comments</comments>
		<pubDate>Mon, 16 Jun 2008 18:36:43 +0000</pubDate>
		<dc:creator>Matt Pruitt</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://guitsaru.wordpress.com/?p=14</guid>
		<description><![CDATA[I&#8217;m working on a site that has a fixed page height and should not scroll. Because of this, the amount of text displayed on a page needs to not exceed a maximum value. I wrote the following function to break a string into lines based on either line breaks, or the amount of characters that [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=guitsaru.wordpress.com&amp;blog=2453834&amp;post=14&amp;subd=guitsaru&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on a site that has a fixed page height and should not scroll.  Because of this, the amount of text displayed on a page needs to not exceed a maximum value.  I wrote the following function to break a string into lines based on either line breaks, or the amount of characters that can fit across the div.</p>
<p>Ruby 1.9 already has a function to break a string into <a href="http://www.ruby-doc.org/core/classes/String.html#M000775">lines</a>; however, this does not include the option to break up a line based on characters and I am still on Ruby 1.8.6.</p>
<p><pre class="brush: ruby;">
def lines s, chars=0
  string = s
  line_array = Array.new
  while(string.size &gt; 0)
    i = string.index(&quot;\n&quot;)
    
    # Takes the string up to either the first line break
    line = string.slice!(0..(i || string.size - 1)).chomp
    
    # Breaks the line up into separate lines based on the number of characters
    if line.size &gt; chars &amp;&amp; chars &gt; 0
      while(line.size &gt; chars)
        ending = chars - 1
        unless line[ending + 1, 1] == &quot; &quot;
          ending = line.size - 1 - line.reverse.index(&quot; &quot;, -ending)
        end
        line_array &lt;&lt; line.slice!(0..ending).strip
      end
    end
    
    line_array &lt;&lt; line.strip
  end
  return line_array
end
</pre></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/guitsaru.wordpress.com/14/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/guitsaru.wordpress.com/14/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/guitsaru.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/guitsaru.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/guitsaru.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/guitsaru.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/guitsaru.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/guitsaru.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/guitsaru.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/guitsaru.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/guitsaru.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/guitsaru.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/guitsaru.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/guitsaru.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/guitsaru.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/guitsaru.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=guitsaru.wordpress.com&amp;blog=2453834&amp;post=14&amp;subd=guitsaru&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://guitsaru.wordpress.com/2008/06/16/break-strings-into-separate-lines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ff7e19f08834700cc9613bbcc986227a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">guitsaru</media:title>
		</media:content>
	</item>
		<item>
		<title>Document Monitoring with Ruby</title>
		<link>http://guitsaru.wordpress.com/2008/05/29/document-monitoring-with-ruby/</link>
		<comments>http://guitsaru.wordpress.com/2008/05/29/document-monitoring-with-ruby/#comments</comments>
		<pubDate>Thu, 29 May 2008 21:13:50 +0000</pubDate>
		<dc:creator>Matt Pruitt</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://guitsaru.wordpress.com/?p=12</guid>
		<description><![CDATA[I have started a project at work to monitor log files and send any errors to the engineers. I played around with it in Ruby and in no time had the code below, which worked wonderfully. Unfortunately, due to the way this particular project is deployed, ruby was not an option. Feel free to use [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=guitsaru.wordpress.com&amp;blog=2453834&amp;post=12&amp;subd=guitsaru&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have started a project at work to monitor log files and send any errors to the engineers.  I played around with it in Ruby and in no time had the code below, which worked wonderfully.  Unfortunately, due to the way this particular project is deployed, ruby was not an option.  Feel free to use this if you need to monitor files for changes.</p>
<p><pre class="brush: ruby;">
require 'ftools'

log_file = &quot;test.log&quot;
last_change = File.mtime(log_file)

while(true)
  if File.readable?(log_file) &amp;&amp; (file_time = File.mtime(log_file)) &gt; last_change
    last_change = file_time
    puts &quot;Log has been updated&quot;
  end
end
</pre></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/guitsaru.wordpress.com/12/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/guitsaru.wordpress.com/12/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/guitsaru.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/guitsaru.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/guitsaru.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/guitsaru.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/guitsaru.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/guitsaru.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/guitsaru.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/guitsaru.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/guitsaru.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/guitsaru.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/guitsaru.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/guitsaru.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/guitsaru.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/guitsaru.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=guitsaru.wordpress.com&amp;blog=2453834&amp;post=12&amp;subd=guitsaru&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://guitsaru.wordpress.com/2008/05/29/document-monitoring-with-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ff7e19f08834700cc9613bbcc986227a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">guitsaru</media:title>
		</media:content>
	</item>
		<item>
		<title>rbVimeo release</title>
		<link>http://guitsaru.wordpress.com/2008/04/11/rbvimeo-release/</link>
		<comments>http://guitsaru.wordpress.com/2008/04/11/rbvimeo-release/#comments</comments>
		<pubDate>Sat, 12 Apr 2008 05:35:39 +0000</pubDate>
		<dc:creator>Matt Pruitt</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[rbvimeo]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[vimeo]]></category>

		<guid isPermaLink="false">http://guitsaru.wordpress.com/?p=8</guid>
		<description><![CDATA[Today I have released the first version of the rbVimeo gem. This is a ruby wrapper for the Vimeo API. To install the gem, run the following command: sudo gem install rbvimeo To demonstrate this library, I have created a simple rails app that takes a video&#8217;s id and displays that video on the page. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=guitsaru.wordpress.com&amp;blog=2453834&amp;post=8&amp;subd=guitsaru&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today I have released the first version of the rbVimeo gem.  This is a ruby wrapper for the <a href="http://www.vimeo.com">Vimeo</a> API.  To install the gem, run the following command:</p>
<pre>sudo gem install rbvimeo</pre>
<p>To demonstrate this library, I have created a simple rails app that takes a video&#8217;s id and displays that video on the page.</p>
<p>index.html.erb:</p>
<p><pre class="brush: ruby;">
 &lt;%- form_remote_tag :url =&gt; { :action =&gt; 'search' },
 	:update =&gt; 'video',
 	:before =&gt; %(Element.show(spinner)),
 	:success =&gt; %(Element.hide(spinner)) do -%&gt;
 &lt;%= image_tag 'spinner.gif', :id =&gt; 'spinner',
 	:style =&gt; 'display: none'%&gt;

	&lt;label for=&quot;video_id&quot;&gt;Video ID:&lt;/label&gt;
 &lt;%= text_field_tag 'video_id' %&gt;
 &lt;%= submit_tag 'Search' %&gt;
 &lt;% end %&gt;
 &lt;div id=&quot;video&quot;&gt;&lt;/div&gt;
</pre></p>
<p>The index takes the Vimeo video&#8217;s id and pushes it to the controller action for search.</p>
<p>vimeo_controller.rb:</p>
<p><pre class="brush: ruby;">
class VimeoController &lt; ApplicationController
  def search
    vimeo = RBVIMEO::Vimeo.new(&quot;api_key&quot;, &quot;api_secret&quot;)
    render :partial =&gt; &quot;video.html.erb&quot;,
 	  :locals =&gt; {:video =&gt; vimeo.video(params[:video_id])}
  end
end
</pre></p>
<p>This then sends the video object into the video partial which embeds it into the video div from the index.</p>
<p>_video.html.erb:</p>
<p><pre class="brush: ruby;">
&lt;%= video.embed(video.width, video.height) %&gt;
</pre></p>
<p>Here is a video that shows the final application</p>
<div class='embed-vimeo' style='text-align:center;'><iframe src='http://player.vimeo.com/video/888809' width='400' height='300' frameborder='0'></iframe></div>
<p><a href="http://rbvimeo.rubyforge.org/">rbVimeo Documentation</a><br />
<a href="http://github.com/guitsaru/rbvimeo/">Github project</a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/guitsaru.wordpress.com/8/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/guitsaru.wordpress.com/8/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/guitsaru.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/guitsaru.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/guitsaru.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/guitsaru.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/guitsaru.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/guitsaru.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/guitsaru.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/guitsaru.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/guitsaru.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/guitsaru.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/guitsaru.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/guitsaru.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/guitsaru.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/guitsaru.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=guitsaru.wordpress.com&amp;blog=2453834&amp;post=8&amp;subd=guitsaru&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://guitsaru.wordpress.com/2008/04/11/rbvimeo-release/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ff7e19f08834700cc9613bbcc986227a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">guitsaru</media:title>
		</media:content>
	</item>
		<item>
		<title>Project 2</title>
		<link>http://guitsaru.wordpress.com/2008/03/04/project-2/</link>
		<comments>http://guitsaru.wordpress.com/2008/03/04/project-2/#comments</comments>
		<pubDate>Tue, 04 Mar 2008 21:09:24 +0000</pubDate>
		<dc:creator>Matt Pruitt</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://guitsaru.com/2008/03/04/project-2/</guid>
		<description><![CDATA[The second project was due yesterday so I can write about it now. This project had two separate parts, approximating e^x by using the sum 1 + x + x^2/2! + x^3/3! + &#8230; + x^n/n!. The second part was a program that determines the number of servings of a type of food needed to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=guitsaru.wordpress.com&amp;blog=2453834&amp;post=7&amp;subd=guitsaru&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The second project was due yesterday so I can write about it now.  This project had two separate parts, approximating e^x by using the sum 1 + x + x^2/2! + x^3/3! + &#8230; + x^n/n!.  The second part was a program that determines the number of servings of a type of food needed to maintain a person&#8217;s current weight based on calories used in a day.  Neither of these are particularly exciting, so I&#8217;ll just show off some a little bit of the code.</p>
<p><pre class="brush: cpp;">
bool repeat_program()
{
	bool valid = false;
	do
	{
		char repeat;
		cout &lt;&lt; repeat;
		if(cin.fail())
		{
			cin.clear();
			cin.ignore(1000, 'n');
			valid = false;
		}
		else if(tolower(repeat) == 'y' )
		{
			valid = true;
			return true;
		}
		else if(tolower(repeat) == 'n' )
		{
			valid = true;
			return false;
		}
		else
		{
			valid = false;
		}
	}while(!valid);
}</pre></p>
<p>This is pretty much exactly the same code that I used to repeat the program in my last project.  Instead of cluttering up the main function, I decided to refactor it into it&#8217;s own function.  I think that this makes the main function much less ugly and a lot easier to follow.  I used this function in both parts of the project and will continue to use it in the future projects.</p>
<p><pre class="brush: cpp;">
double get_positive_double(string prompt)
{
	double input;
	bool valid = false;
	do
	{
		cout  input;
		if(cin.fail())
		{
			cin.clear();
			cin.ignore(1000, 'n');
			valid = false;
			cout &lt;&lt; &quot;The input must be a number.&quot; &lt;&lt; endl;
		}
		else if(input &lt;= 0)
		{
			cout &lt;&lt; &quot;The input must be greater than 0.&quot; &lt;&lt; endl;
			valid = false;
		}
		else
		{
			return input;
		}
	}while(!valid);
}</pre></p>
<p>As I said in my last post, I revamped my input checking code in addition to putting it into it&#8217;s own function.  Again, this serves to make the main function a lot less ugly and easier to follow.  <a href="http://guitsaru.googlepages.com/body_weight.cpp">body_weight.cpp</a> <a href="http://guitsaru.googlepages.com/e.cpp">e.cpp</a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/guitsaru.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/guitsaru.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/guitsaru.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/guitsaru.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/guitsaru.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/guitsaru.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/guitsaru.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/guitsaru.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/guitsaru.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/guitsaru.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/guitsaru.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/guitsaru.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/guitsaru.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/guitsaru.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/guitsaru.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/guitsaru.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=guitsaru.wordpress.com&amp;blog=2453834&amp;post=7&amp;subd=guitsaru&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://guitsaru.wordpress.com/2008/03/04/project-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ff7e19f08834700cc9613bbcc986227a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">guitsaru</media:title>
		</media:content>
	</item>
		<item>
		<title>Programming Project #1</title>
		<link>http://guitsaru.wordpress.com/2008/02/20/programming-project-1/</link>
		<comments>http://guitsaru.wordpress.com/2008/02/20/programming-project-1/#comments</comments>
		<pubDate>Wed, 20 Feb 2008 23:58:58 +0000</pubDate>
		<dc:creator>Matt Pruitt</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://guitsaru.com/?p=5</guid>
		<description><![CDATA[Well, my first official college programming project has been turned in. A government research lab has concluded that an artificial sweetener commonly used in diet soda pop will cause death in laboratory mice. A friend of yours is desperate to lose weight, but cannot give up soda pop. Your friend wants to know how much [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=guitsaru.wordpress.com&amp;blog=2453834&amp;post=5&amp;subd=guitsaru&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Well, my first official college programming project has been turned in.  </p>
<blockquote><p>
A government research lab has concluded that an artificial sweetener commonly used in diet soda pop will cause death in laboratory mice.  A friend of yours is desperate to lose weight, but cannot give up soda pop.  Your friend wants to know how much diet soda pop it is possible to drink without dying as a result.  Write a program to supply the answer.  The input to the program is the amount of artificial sweetener needed to kill a mouse, the weight of the mouse, and the weight of the dieter.  To ensure the safety of your friend, be sure the program requests the weight at which the dieter will stop dieting, rather than the dieter&#8217;s current weight.  Assume that diet soda contains 1/10th of 1% artificial sweetener.  Use a variable declaration with the modifier const to give a name to this fraction.  You may want to express the percent as the double value 0.001.  Your program should allow the calculation to be repeated as often as the user wishes.
</p></blockquote>
<p>The project outline was really vague and gives a great lesson on project specifications.  The required information was not present in the outline, information such as how is the diet soda measured?  I resorted to measuring everything in ounces, which is awkward when measuring a liquid such as diet soda (the measurement is expected to be in fluid ounces, but in this case must be in mass form).</p>
<p>Below, I will highlight a few of the more interesting pieces of code.</p>
<p><pre class="brush: cpp;">
do{
	cout &lt;&lt; mouse_weight;
	if(mouse_weight &lt;= 0)
		cout &lt;&lt; &quot;Input must be greater than 0.&quot; 
		     &lt;&lt; endl &lt;&lt; endl;
}while(mouse_weight &lt;= 0);
</pre></p>
<p>In this loop, I prompt for the weight of the mouse and continue to test until I get a valid result (mice don&#8217;t usually have a negative weight).  This loop is not perfect, when it receives unexpected input, it goes into an infinite loop:</p>
<p><code><br />
	Weight of the mouse (in ounces): a<br />
	Input must be greater than 0.<br />
	Weight of the mouse (in ounces): Input must be greater than 0.<br />
	Weight of the mouse (in ounces): Input must be greater than 0.<br />
	Weight of the mouse (in ounces): Input must be greater than 0.<br />
	Weight of the mouse (in ounces): Input must be greater than 0.<br />
</code></p>
<p>In Project #2, I added a function to do all of this work for me; essentially, I call get_positive_double() and it returns a double while handling erroneous input (negatives, zero, and characters), plus it looks a whole lot cleaner.  Unfortunately, I can&#8217;t show you this yet because the project isn&#8217;t due for a few weeks.  Check back then to approximate e^x and to see how many servings of your favorite food it takes to maintain your current weight.</p>
<p>Click <a href="http://guitsaru.googlepages.com/diet_soda.cpp">here</a> to download the full source code.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/guitsaru.wordpress.com/5/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/guitsaru.wordpress.com/5/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/guitsaru.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/guitsaru.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/guitsaru.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/guitsaru.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/guitsaru.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/guitsaru.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/guitsaru.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/guitsaru.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/guitsaru.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/guitsaru.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/guitsaru.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/guitsaru.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/guitsaru.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/guitsaru.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=guitsaru.wordpress.com&amp;blog=2453834&amp;post=5&amp;subd=guitsaru&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://guitsaru.wordpress.com/2008/02/20/programming-project-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/ff7e19f08834700cc9613bbcc986227a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">guitsaru</media:title>
		</media:content>
	</item>
	</channel>
</rss>
