CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: Help Required

  1. #1
    Join Date
    Feb 2005
    Posts
    6

    Help Required

    I need someone to write the code for the following program:



    I've created the interface but the code is what i cant do. Any help would be much appreciated.

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Help Required

    First, you did not actually explain what the problem is. Do you need a program that parses a string to check how many words of a certain length are there?

    How much will you pay?

    Code:
    using System;
    using System.Text.RegularExpressions;
    using System.Text;
    using System.Collections;
    
    namespace ParserNamespace
    {
    	class Class1
    	{
    		public int[] ParseString(String text)
    		{
    			int [] vector = new int[6];
    			Regex reg = new Regex(" |, | ,|,");
    
    			StringBuilder sbuilder = new StringBuilder();
    
    			foreach(string s in reg.Split(text))
    			{
    				if(s.Length<6) vector[s.Length-1]++;
    				else vector[vector.Length-1]++;
    			}
    
    			return vector;
    		}
    
    		[STAThread]
    		static void Main(string[] args)
    		{
    			Class1 test = new Class1();
    			int [] results = test.ParseString("this is just a simple text,nothing more, nothing less");
    
    			int i=1;
    			foreach(int val in results)
    			{
    				Console.WriteLine("Words of length {0} : {1}",i++,val);
    			}
    		}
    	}
    }
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  3. #3
    Join Date
    Feb 2005
    Posts
    6

    Re: Help Required

    How much do you cost?

  4. #4
    Join Date
    Feb 2005
    Posts
    6

    Re: Help Required

    The program should calculate and display the number of words that contain 1, 2, 3, 4 or 5 characters as shown in the example. Any words that contain 6 or more characters should be counted together.

    If the user does not enter a string before pressing the button, an error message should be displayed and the user asked to enter another string.

    The program should be able to handle situations where there is more than one space between the words in the sentence. Punctuation characters such as comma, full-stop, etc can be treated as characters in words.

  5. #5
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Help Required

    Are you familiar to C# or not? What I've written basically does want you need, except that is a console application. I'm sorry, but I'm not going to write the entire application for you.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  6. #6
    Andy Tacker is offline More than "Just Another Member"
    Join Date
    Jun 2001
    Location
    55°50' N 37°39' E
    Posts
    1,503

    Re: Help Required

    Rob316, you can offer someone to write code for you in JOBS Forum.
    If you think you CAN, you can, If you think you CAN'T, you are probably right.

    Have some nice Idea to share? Write an Article Online or Email to us and You may WIN a Technical Book from CG.

  7. #7
    Join Date
    Feb 2005
    Posts
    6

    Re: Help Required

    Your code doesnt work

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured