Let Share Codes

Welcome. Please Login, Register, Or Activate! 
type your username and password to login
Date: November 23, 2009, 02:53 AM
431038 members and 298111 Topics
Latest Member: kimmek
Nairaland [Nigerian Forum] Home Help Search Who is currently online? Login Register
Nairaland Forum  |  Technology  |  Programming  |  Let Share Codes
Pages: (1) (2) Go Down Send this topic Notify of replies
Author Topic: Let Share Codes  (Read 1991 views)
krazied (m)
Re: Let Share Codes
« #32 on: November 06, 2007, 04:32 PM »

hey guyz am a student just studied c and trying to practice but can't seem to make my compiler work is there anywhere to get a c compiler better still java's and how do you use d java runtime enviroment just downloaded one pls try being explicit   Cry
SayoMarvel (m)
Re: Let Share Codes
« #33 on: November 11, 2007, 05:45 PM »

I don't know if anyone needs the source code of my simple application that calculates the determinant of a 3 by 3 square maltrix.
Smart K. (m)
Re: Let Share Codes
« #34 on: November 12, 2007, 01:01 PM »

Quote
I don't know if anyone needs the source code of my simple application that calculates the determinant of a 3 by 3 square maltrix.

You have tried man. Keep it up. I did exactly that, about 8 years ago when learning C. You can push it a little 4ward by use it to solve 3X3 simultaneous eqns. I mean real life situations like determining prices of known items.

Good luck.
Smart K. (m)
Re: Let Share Codes
« #35 on: November 12, 2007, 05:26 PM »

Here is the code that converts amount in double to amount in words. I did it in C#. You may copy and use it if u like. It uses Nigeria currency :

Usage: AmountInWord(115.50) returns one hundred and fifteen naira fifty kobo only.

public static string AmountInWord(string amount)
        {
            long num;
            long num2;
            string str2;
            string str3;
            string str = "";
            string[] strArray = new string[5];
            amount = amount.Replace(",", "");
            amount = amount.Replace(" ", "");
            str = "";
            try
            {
                double num3 = double.Parse(amount);
            }
            catch
            {
                throw new Exception("The amount supplied is not a number and therefore not convertuble");
            }
            strArray[0] = "Trillion ";
            strArray[1] = "Billion ";
            strArray[2] = "Million ";
            strArray[3] = "Thousand ";
            strArray[4] = " ";
            int index = amount.IndexOf(".");
            if (index > -1)
            {
                str2 = amount.Substring(0, index);
                str3 = amount.Substring(index, amount.Length - index);
                if (str2.Length > 15)
                {
                    throw new Exception("The amount supplied must not be greater than 999 999 999 999 999.99");
                }
                str2 = string.Format("{0:D15}", long.Parse(str2));
                str3 = string.Format("{0:F2}", double.Parse(str3));
            }
            else
            {
                if (amount.Length > 15)
                {
                    throw new Exception("The amount supplied must not be greater than 999 999 999 999 999.99");
                }
                str2 = string.Format("{0:D15}", long.Parse(amount));
                str3 = "0.00";
            }
            amount = str2 + str3.Substring(1, 3);
            int num5 = 0;
            for (int i = 0; num5 <= 4; i += 3)
            {
                if (long.Parse(amount.Substring(i, 3)) > 0)
                {
                    if (long.Parse(amount.Substring(i, 1)) > 0)
                    {
                        num = long.Parse(amount.Substring(i + 1, 1));
                        num2 = long.Parse(amount.Substring(i + 2, 1));
                        if ((num > 0) || (num2 > 0))
                        {
                            str = str + convert(amount.Substring(i, 1)) + "Hundred And ";
                        }
                        else
                        {
                            str = str + convert(amount.Substring(i, 1)) + "Hundred ";
                        }
                    }
                    num = long.Parse(amount.Substring(i + 1, 2));
                    num2 = long.Parse(amount.Substring(i + 1, 2));
                    if ((num >= 20) && (num2 <= 0x63))
                    {
                        num = long.Parse(amount.Substring(i + 1, 1) + "0");
                        num2 = long.Parse(amount.Substring((i + 1) + 1, 1));
                        str = str + convert(num) + convert(num2);
                    }
                    num = long.Parse(amount.Substring(i + 1, 2));
                    num2 = long.Parse(amount.Substring(i + 1, 2));
                    if ((num >= 1) && (num2 < 20))
                    {
                        str = str + convert(amount.Substring(i + 1, 2));
                    }
                    str = str + strArray[num5];
                }
                num5++;
            }
            if (long.Parse(amount.Substring(0, 15)) > 0)
            {
                str = str + "naira ";
            }
            num = int.Parse(amount.Substring(amount.Length - 2, 2));
            if (num > 0)
            {
                num = long.Parse(amount.Substring(amount.Length - 2, 2));
                num2 = long.Parse(amount.Substring(amount.Length - 2, 2));
                if ((num >= 20) && (num2 <= 0x63))
                {
                    num = long.Parse(amount.Substring(0x10, 1) + "0");
                    num2 = long.Parse(amount.Substring(0x11, 1));
                    str = str + convert(num) + convert(num2);
                }
                num = long.Parse(amount.Substring(amount.Length - 2, 2));
                if ((num >= 1) && (num < 20))
                {
                    str = str + convert(amount.Substring(amount.Length - 2, 2));
                }
                str = str + "kobo ";
            }
            return (str + "only").ToLower();
        }

        private static string convert(long amount)
        {
            return convert(amount.ToString());
        }

        private static string convert(string amount)
        {
            switch (int.Parse(amount))
            {
                case 70:
                    return "seventy ";

                case 80:
                    return "eighty ";

                case 90:
                    return "ninety ";

                case 0:
                    return "";

                case 1:
                    return "one ";

                case 2:
                    return "two ";

                case 3:
                    return "three ";

                case 4:
                    return "four ";

                case 5:
                    return "five ";

                case 6:
                    return "six ";

                case 7:
                    return "seven ";

                case 8:
                    return "eight ";

                case 9:
                    return "nine ";

                case 10:
                    return "ten ";

                case 11:
                    return "eleven ";

                case 12:
                    return "twelve ";

                case 13:
                    return "thirteen ";

                case 14:
                    return "fouteen ";

                case 15:
                    return "fifteen ";

                case 0x10:
                    return "sixteen ";

                case 0x11:
                    return "seventeen ";

                case 0x12:
                    return "eighteen ";

                case 0x13:
                    return "nineteen ";

                case 20:
                    return "twenty ";

                case 30:
                    return "thirty ";

                case 40:
                    return "fourty ";

                case 50:
                    return "fifty ";

                case 60:
                    return "sixty ";
            }
            return "";
        }

        public static bool IsNumeric(string val)
        {
            try
            {
                double num = double.Parse(val);
                return true;
            }
            catch
            {
                return false;
            }
        }

Good luck
yinka007 (m)
Re: Let Share Codes
« #36 on: November 15, 2007, 11:43 AM »

i think it will be better to share codes as attachments or using URL's eg. http://www.spiralteck.com
Smart K. (m)
Re: Let Share Codes
« #37 on: May 12, 2008, 11:32 AM »

Long time! Cooking up something ,  Sorry, I was away for a long time.
Smart K. (m)
Re: Let Share Codes
« #38 on: April 24, 2009, 06:51 PM »

Hi guys, long time no see. Been busy with lots of projects recently.
OK let share this sample code to send mail HTML page using gmail server in C#:

  private String readHtmlPage(string url)
        {
            if (!System.IO.File.Exists(url)) return string.Empty;

            try
            {
                String result;
                WebResponse objResponse;
                WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
                objResponse = objRequest.GetResponse();
                using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
                {
                    result = sr.ReadToEnd();
                    sr.Close();
                }
                return result;
            }
            catch (Exception ex)
            {
                App.LogError(ex);
                return string.Empty;
            }
        }


 private void SendMailBtn_Click(object sender, EventArgs e)
        {               
                string mail = readHtmlPage(url);
                if (mail.Trim().Length == 0) return;

                string toAddress = "to_one@yahoo.co.uk";
                string fromAddress = "someone@gmail.com";

            try
            {
            
               if (fromAddress.Trim().Length == 0)
               {
                  MessageBox.Show(this, "Cannot send mail from an empty address. Please confirm the setting email.", "Byaxiom SendMail", MessageBoxButtons.OK, MessageBoxIcon.Information);
                  return;
               }
               if (toAddress.Trim().Length == 0)
               {
                  MessageBox.Show(this, "Cannot send mail to an empty address. Please confirm the customer email.", "Byaxiom SendMail", MessageBoxButtons.OK, MessageBoxIcon.Information);
                  return;
               }

               MailMessage msg = new MailMessage();
               msg.IsBodyHtml = true;
               msg.From = new MailAddress(fromAddress);
               msg.To.Add(toAddress);
               if (AppSettings.Default.EMailCopy.Length > 0)
                  msg.CC.Add("mycopyemail@yahoo.com");

               msg.Subject = subject;
               msg.Body = message;

               SmtpClient mailClient = new SmtpClient("smtp.gmail.com", 587);
               mailClient.EnableSsl = true;
               NetworkCredential cred = new NetworkCredential(toAddress, "fromAddresspassword");
               mailClient.Credentials = cred;

               mailClient.Send(msg);
               MessageBox.Show(this, "Track report mail sent to " + toAddress + ". Please confirm by checking your mail copy", "Byaxiom SendMail", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
               App.LogError(ex);
               MessageBox.Show(this, "There was an error sending mail. Please check your setings and internet connection.", "Byaxiom SendMail", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }            
        }
blacksta (m)
Re: Let Share Codes
« #39 on: April 24, 2009, 07:43 PM »

@smark k

what would say is the best way of becoming a comptetent programmer in any choosen language. or could share scerets that has worked for you

thanks
Smart K. (m)
Re: Let Share Codes
« #40 on: April 30, 2009, 11:08 AM »

@blacksta

i. Have genuine interest in programming
ii. Sincerely ask yourself if u have what it takes
iii. Be consistent. It takes time to get used to programming
iv. Always be prepared to go some extra-mile. Go a step higher than the next person
v. Always open your mind. Never close your mind door. U could always find a better way of doing it.

Hey, manage this for now. Thanx
cdeveloper (m)
Re: Let Share Codes
« #41 on: May 11, 2009, 02:27 PM »

I like this post and i think i have started something on this line before. Well I created a blog on www.youbanize.com recently because i wanted to create a place online to share programming experiences. I am a PHP programmer, a veteran in JavaScript and CSS. I have posted some of my codes in there;if you would like to share real experiences or learn from the experiences of others , you are welcome.
textmypage (m)
Re: Let Share Codes
« #42 on: May 18, 2009, 01:44 AM »

where can i get JDk and its product key to install
okunade (m)
Re: Let Share Codes
« #43 on: May 18, 2009, 12:10 PM »

go to java.sun.com
textmypage (m)
Re: Let Share Codes
« #44 on: May 20, 2009, 06:59 AM »

Where can i get java file editor to download?
textmypage (m)
Re: Let Share Codes
« #45 on: May 20, 2009, 07:07 AM »

and I use Windows XP Professional 2008.make una help me out
 Towards A Stronger Nigerian Software Industry  What Software Have You Created [remix]  How Can I Practice Programming on My PC?  Page 2
Pages: (1) (2) Go Up Send Topic to Friend by E-mail Reply 


Sections: Autos/Cars (2) Jobs/Vacancies (2) (3) Career Talk Education General(2) Politics Romance Computers Phones Travel
Sports Fashion Health Religion Celebrities TV/Movies (2) Music/Radio (2) Books Webmasters Programming

Links: Page1 Page2 Page3 Page4 Page5 Page6 Page7 Page8 Page9 Page10

Nairaland is owned by Oluwaseun Osewa. See also: Nairalist Classified Ads
Nairaland Forum | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.