tag:blogger.com,1999:blog-6635871796411375052.post2053892169997296158..comments2023-10-27T01:39:53.381-06:00Comments on Thoughts, Perception, and Point of View: PPP: The Sum of DigitsLevi Wattshttp://www.blogger.com/profile/12290268199961755004noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-6635871796411375052.post-7795530824680225542011-08-29T01:52:48.004-06:002011-08-29T01:52:48.004-06:00By the way, I did not program any validation check...By the way, I did not program any validation checking for input.J. Ashhttps://www.blogger.com/profile/03855460323433000416noreply@blogger.comtag:blogger.com,1999:blog-6635871796411375052.post-83186264063065586712011-08-28T23:11:09.333-06:002011-08-28T23:11:09.333-06:00using System;
using System.Collections;
using Syst...using System;<br />using System.Collections;<br />using System.Configuration;<br />using System.Data;<br />using System.Linq;<br />using System.Web;<br />using System.Web.Security;<br />using System.Web.UI;<br />using System.Web.UI.HtmlControls;<br />using System.Web.UI.WebControls;<br />using System.Web.UI.WebControls.WebParts;<br />using System.Xml.Linq;<br /><br />namespace SumOfInput<br />{<br /> public partial class _Default : System.Web.UI.Page<br /> {<br /><br /> protected void Page_Load(object sender, EventArgs e)<br /> {<br /><br /> lblTitle.Text = "Welcome to The Sum of Digits";<br /> lblInstructions.Text = "Input an integer of any length and press 'Get Sum!' to find the sum of all digits entered.";<br /> lblResult.Text = "";<br /> }<br /><br /> protected void btnGetSum_Click(object sender, EventArgs e)<br /> {<br /> int iDigit, iCount, iLen;<br /> string sub, input, result;<br /><br /> input = txtInput.Text;<br /><br /> iLen = input.Length;<br /> iDigit = 1;<br /><br /> int[] digits;<br /> digits = new int[iLen];<br /><br /> for (iCount = 0; iCount < iLen; iCount++)<br /> {<br /> sub = input.Substring(iCount, iDigit);<br /> digits[iCount] = int.Parse(sub);<br /> }<br /><br /> result = digits.Sum().ToString();<br /><br /> lblResult.Text = "The sum of your digits is " + result;<br /> }<br /><br /> protected void btnClear_Click(object sender, EventArgs e)<br /> {<br /> txtInput.Text = "";<br /> lblResult.Text = "";<br /> }<br /> }<br />}J. Ashhttps://www.blogger.com/profile/03855460323433000416noreply@blogger.com