.....................
Page 1 of 1
Delete It
#1
Posted 20 August 2008 - 06:28 AM
#3
Posted 20 August 2008 - 08:41 AM
Not sure what language you're programming in. It'd be helpful to know =p because you can exploit some nice APIs.
There's a few ways you can do this; you could use modulo to find out place/roots. I remember doing that along time ago. However, since you might be near the end of the quarter. You might want to try to use a 2D array with a switch case or even with recursion (which might be best).
To make it more fun, I'd employ an fstream for the 2D array. Such that you can get cases like 20 = Twenty, 30 = Thirty, 12 = Twelve. A few numbers that don't follow the conventional naming rules.
And, if possible, see if you can do it as 92000 instead of 92,000. That , is a lot of extra code you may or may not need to do. Might also think about evaluating the string too. Use strlen to get the length of the string, you can do int var = strlen btw.
But, I suppose I can write up something to give you an idea.
That's the 2D array, but can be easily broken down using fstream. Here's an idea how to get the high count
The calculating part of it is a bit difficult, since you have to keep track of operation rules. Such as, 5 + 5 * 5 = 30. Make sure you're doing 5 * 5 first, then add 5. You can do this through recursion.
There's a few ways you can do this; you could use modulo to find out place/roots. I remember doing that along time ago. However, since you might be near the end of the quarter. You might want to try to use a 2D array with a switch case or even with recursion (which might be best).
To make it more fun, I'd employ an fstream for the 2D array. Such that you can get cases like 20 = Twenty, 30 = Thirty, 12 = Twelve. A few numbers that don't follow the conventional naming rules.
And, if possible, see if you can do it as 92000 instead of 92,000. That , is a lot of extra code you may or may not need to do. Might also think about evaluating the string too. Use strlen to get the length of the string, you can do int var = strlen btw.
But, I suppose I can write up something to give you an idea.
CODE
char ones_place_array[10][11] = { " ", "one", "two", "three" etc.};
char tens_place_array[10][11] = { "ten", "eleven", "twelve", etc.};
char other_place_array[#][#+1] = { "twenty", "thirty", "fourty" etc.};
char high_place_array[#][#+1] = { "hundred", "thousand", "million", "billion" etc. };
char tens_place_array[10][11] = { "ten", "eleven", "twelve", etc.};
char other_place_array[#][#+1] = { "twenty", "thirty", "fourty" etc.};
char high_place_array[#][#+1] = { "hundred", "thousand", "million", "billion" etc. };
That's the 2D array, but can be easily broken down using fstream. Here's an idea how to get the high count
CODE
switch(variable size - place)
case 4: strcpy(temp[2nd array variable++], high_place_array[highest # in the array - 1]);
break;
case 4: strcpy(temp[2nd array variable++], high_place_array[highest # in the array - 1]);
break;
The calculating part of it is a bit difficult, since you have to keep track of operation rules. Such as, 5 + 5 * 5 = 30. Make sure you're doing 5 * 5 first, then add 5. You can do this through recursion.
#4
Posted 20 August 2008 - 06:27 PM
QUOTE (THEmerryJANE @ Aug 20 2008, 10:53 AM) <{POST_SNAPBACK}>
What language is it for? I can only help if it's in Java.
This is C++ language. I think is very difficult. I'm a first year student. So..I really need some help.
#5
Posted 20 August 2008 - 09:48 PM
I won't do your homework/final for you, but, I will help you through as long as you post code and give me an idea of what you're going to do or trying to do. Post what you have up so far.
Whether it be actual code or psuedocode, and if you do post code post it with the notation/comments. It'd be helpful also if you state how you'd solve it.
Whether it be actual code or psuedocode, and if you do post code post it with the notation/comments. It'd be helpful also if you state how you'd solve it.
#6
Posted 21 August 2008 - 04:30 AM
QUOTE (miney2 @ Aug 20 2008, 08:27 PM) <{POST_SNAPBACK}>
This is C++ language. I think is very difficult. I'm a first year student. So..I really need some help.
Damn I don't really know C++. But, like AngeloDS said, post up what you have even if it's just barely your ideas on how to construct the calculator.
Share this topic:
Page 1 of 1











