User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 427,494 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,464 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C# advertiser: Programming Forums
Views: 1732 | Replies: 5
Reply
Join Date: Nov 2006
Posts: 4
Reputation: _Soul_ is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
_Soul_ _Soul_ is offline Offline
Newbie Poster

Help HailStone

  #1  
Nov 8th, 2006
Hi everybody

I already see in this forum how to make the program Hailstone Numbers in c++

But i need to make it in c#

Could any charity soul help me plese...
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2005
Posts: 4,782
Reputation: iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light 
Rep Power: 17
Solved Threads: 319
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Industrious Poster

Re: HailStone

  #2  
Nov 10th, 2006
This couldn't be easier.

Have you drawn a flow chart? If not do so.
I'm not a programmer. My attitude starts with ignorance, holds steady at conversation, and ends with a trip to the hospital. Get used to it.
Reply With Quote  
Join Date: Oct 2006
Location: Idaho
Posts: 44
Reputation: Godfear1 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 3
Godfear1's Avatar
Godfear1 Godfear1 is offline Offline
Light Poster

Re: HailStone

  #3  
Nov 13th, 2006
Hey, this hailstone numbers thing is pretty cool. Apparently there are some rewards out there for anyone who can solve it (whatever that means.) I embarrased myself the other day when I resserected a very old topic in the C++ C forum from two years ago asking a question about this. (Sorry about that mods!) Anyway, I don't code very well in C++ though I tried to do it. I just coded it in C#. So here it is. Sorry about the delay, I had finals.

  1. using System;
  2. using System.Text;
  3. namespace ConsoleApplication1
  4. {
  5. class Program
  6. {
  7. // Helpful url: [url]http://en.wikipedia.org/wiki/Hailstone_numbers[/url]
  8. static void Main(string[] args)
  9. {
  10. int first;
  11. System.Console.WriteLine("Enter the integer you would like to run the function on: ");
  12. first = int.Parse(System.Console.ReadLine());
  13. while (first != 1)
  14. {
  15. System.Console.Write(first + " ");
  16. first = f(first);
  17. }
  18. System.Console.WriteLine(first);
  19. System.Console.WriteLine("Press enter to continue.");
  20. ConsoleKeyInfo c = System.Console.ReadKey();
  21. while (c.Key != ConsoleKey.Enter)
  22. {
  23. c = System.Console.ReadKey();
  24. }
  25. }
  26. private static int f(int first)
  27. {
  28. if (first % 2 == 0)//test to see if even
  29. {
  30. return first /= 2;
  31. }
  32. else
  33. {
  34. return first = 3 * first + 1;//is odd
  35. }
  36. }
  37. }
  38. }
  39.  
Reply With Quote  
Join Date: Aug 2005
Posts: 4,782
Reputation: iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light 
Rep Power: 17
Solved Threads: 319
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Industrious Poster

Re: HailStone

  #4  
Nov 14th, 2006
Hi Godfear, don't worry about that, we all learn from our mistakes.

However, remember daniweb's homework policy. We don't do ppl's homework, especially if the poster has shown no sign of effort.
I'm not a programmer. My attitude starts with ignorance, holds steady at conversation, and ends with a trip to the hospital. Get used to it.
Reply With Quote  
Join Date: Nov 2006
Posts: 4
Reputation: _Soul_ is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
_Soul_ _Soul_ is offline Offline
Newbie Poster

Re: HailStone

  #5  
Nov 15th, 2006
thank U it was a BIG BIG help
Reply With Quote  
Join Date: Oct 2006
Location: Idaho
Posts: 44
Reputation: Godfear1 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 3
Godfear1's Avatar
Godfear1 Godfear1 is offline Offline
Light Poster

Re: HailStone

  #6  
Nov 16th, 2006
Your welcome. I hope This wasn't your homework. I don't want to get in trouble for being too helpful.
Last edited by Godfear1 : Nov 17th, 2006 at 12:00 am.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C# Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C# Forum

All times are GMT -4. The time now is 7:02 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC