Please help with this program

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Apr 2009
Posts: 6
Reputation: Doctor Cactus is an unknown quantity at this point 
Solved Threads: 0
Doctor Cactus Doctor Cactus is offline Offline
Newbie Poster

Please help with this program

 
0
  #1
Apr 1st, 2009
Hi, I am only beginning C#, so bear with me. I have been given this program to write. This is the question:


Write a C# application called WRITENUM that inputs a number between 0 and 2,000,000,000 inclusive and outputs that number in textual form, as we would say it or write it normally. For example if we input 1234011811 then the program will output “One billion, two hundred and thirty four million, eleven thousand, eight hundred and eleven.” If we input 0 then the program will output “Zero”. Note that commas and “and”s have been appropriately placed, the first letter of the output is capitalised, words are separated using a single space and the text ends with a full stop. A program such as this might be used as part of a financial package that prints cheques as part of its output, for example.

Your program will create a single form (window) that will allow the user to enter the number at the top and produce the textual equivalent in the middle. The form will have two buttons, a “Convert to text” button which will cause the number input by the user to be shown in textual format. The second button will be an “Exit” button which will cause the program to terminate. The program will allow the user to perform conversions until the program is terminated.

The values supplied by the user must be input into a variable of type int.


Now, I want to know is there a way to do this without having loads of if and else statements checking the numbers entered?
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 436
Reputation: JerryShaw is on a distinguished road 
Solved Threads: 72
JerryShaw JerryShaw is offline Offline
Posting Pro in Training

Re: Please help with this program

 
0
  #2
Apr 1st, 2009
Try using a switch( var.Length ) construct. That should limit you to ten or so case statements.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 18
Reputation: Acedia is an unknown quantity at this point 
Solved Threads: 2
Acedia Acedia is offline Offline
Newbie Poster

Re: Please help with this program

 
0
  #3
Apr 5th, 2009
This sounds like an interesting project.

I'll be able to help you with something like this. However it's going to be a bit of time before i can get something started for you.

are you using Visual c# 2005 or 2008?
do the commas need to be automatically placed in the text box as the user inputs the number, or is it required that the user place the comma's themselves?
Last edited by Acedia; Apr 5th, 2009 at 6:33 pm.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 6
Reputation: Doctor Cactus is an unknown quantity at this point 
Solved Threads: 0
Doctor Cactus Doctor Cactus is offline Offline
Newbie Poster

Re: Please help with this program

 
0
  #4
Apr 6th, 2009
Originally Posted by Acedia View Post
This sounds like an interesting project.

I'll be able to help you with something like this. However it's going to be a bit of time before i can get something started for you.

are you using Visual c# 2005 or 2008?
do the commas need to be automatically placed in the text box as the user inputs the number, or is it required that the user place the comma's themselves?

The user just enters a number in a text box and when they click on the 'Convert to text' button, it displays the text as in the question. I am using SharpDevelop.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 18
Reputation: Acedia is an unknown quantity at this point 
Solved Threads: 2
Acedia Acedia is offline Offline
Newbie Poster

Re: Please help with this program

 
0
  #5
Apr 6th, 2009
Alright I've completed the working code for this, I didn't use cases and well it's sloppy, but works. It's terribly long so i do not feel comfortable pasting the entire code. I will paste the the modules in a tutorial type format, so that i can explain the code. I'll be back to edit in a moment
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 18
Reputation: Acedia is an unknown quantity at this point 
Solved Threads: 2
Acedia Acedia is offline Offline
Newbie Poster

Re: Please help with this program

 
0
  #6
Apr 6th, 2009
For some reason it won't let me edit one of my last post, so sorry for double posting. But here it goes

what I'm going to do, cause this started getting very long, I'm going to post the source code to the program i created earlier for download. You can take what you want from it, but be advised that it's very sloppy, and should not be used as reference in programming.

I hope this helps here's the code, its zipped.
Convert to Text
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 6
Reputation: Doctor Cactus is an unknown quantity at this point 
Solved Threads: 0
Doctor Cactus Doctor Cactus is offline Offline
Newbie Poster

Re: Please help with this program

 
0
  #7
Apr 8th, 2009
I cannot access the link to the zip file. It asks for a username and password. I have provided a screenshot of the problem below

http://www.piccdrop.com/images/1239185225.bmp
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 18
Reputation: Acedia is an unknown quantity at this point 
Solved Threads: 2
Acedia Acedia is offline Offline
Newbie Poster

Re: Please help with this program

 
0
  #8
Apr 8th, 2009
Here's a better link this link is direct, no password required. Sorry about that.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 6
Reputation: Doctor Cactus is an unknown quantity at this point 
Solved Threads: 0
Doctor Cactus Doctor Cactus is offline Offline
Newbie Poster

Re: Please help with this program

 
0
  #9
Apr 9th, 2009
Originally Posted by Acedia View Post
Here's a better link this link is direct, no password required. Sorry about that.

The program works fine. Thanks for your help.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 581 | Replies: 8
Thread Tools Search this Thread



Tag cloud for C#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC