BoSoxFan900
CAGiversary!
- Feedback
- 8 (100%)
I'm taking my first programming class and everything has been going pretty smoothly until now. We have to do the following:
Write a Visual Basic program that will convert a numeric check amount into text.
The check amount can be any value between $.01 and $499.99. This program uses SELECT/CASE and IF statements.
Example:
If you enter $197.18, it will spell out the check amount as
One Hundred Ninety Seven and 18/100 dollars.
Additional info:
First the Calculation.
If I have either of the following statements in a program, what is the answer?
1. 197.18 \ 100 Or
2. Int(197.18 / 100)
The answer to Item #1 is 1. The \ is the symbol for Integer Division. Integer Division is discussed on page 70, item #9.
The answer to Item #2 is 1. 197.18 / 100 equals 1.9718. The Int function will round the 1.9718 to the lowest whole number, which is 1.
If the answer is 1, you concatenate to a string "100 hundred". If you answered had been 2, then you would concatenate to a string "200 hundred", etc.
To do this, use a select case
example:
Case 1:
strAmount = strAmount + "One Hundred "
case 2:
strAmount = strAmount + "Two Hundred "
etc.
After you determine the Hundreds amount, you then deduct it from your check amount.
amount = amount - numberofhundreds * 100
if amount was 197.18 and the number of hundreds was 1, what is the answer to the formula?
amount = 197.18 - 1 * 100 -- 1 * 100 is done first, which your formula now becomes amount = 197.18 - 100 -- then amount would be
amount = 97.18
Next, determine the number of tens remaining in the check amount.
1. 97.18 \ 10 OR
2. int(97.18 / 10)
Answer #1 is 9
Answer #2 is 9.
9 means Ninety; use select to concatenate "Ninety" to the strAmount
then like previous example, subtract the number of tens from the check amount.
Finally, you will end up with only cents.
You will use the select/case to build the check amount as a string.
Does anyone have experience doing things like this? I would really appreciate any help you could give me because I'm completely lost. We're only supposed to use Select Case and If statements in completing the program.
Write a Visual Basic program that will convert a numeric check amount into text.
The check amount can be any value between $.01 and $499.99. This program uses SELECT/CASE and IF statements.
Example:
If you enter $197.18, it will spell out the check amount as
One Hundred Ninety Seven and 18/100 dollars.
Additional info:
First the Calculation.
If I have either of the following statements in a program, what is the answer?
1. 197.18 \ 100 Or
2. Int(197.18 / 100)
The answer to Item #1 is 1. The \ is the symbol for Integer Division. Integer Division is discussed on page 70, item #9.
The answer to Item #2 is 1. 197.18 / 100 equals 1.9718. The Int function will round the 1.9718 to the lowest whole number, which is 1.
If the answer is 1, you concatenate to a string "100 hundred". If you answered had been 2, then you would concatenate to a string "200 hundred", etc.
To do this, use a select case
example:
Case 1:
strAmount = strAmount + "One Hundred "
case 2:
strAmount = strAmount + "Two Hundred "
etc.
After you determine the Hundreds amount, you then deduct it from your check amount.
amount = amount - numberofhundreds * 100
if amount was 197.18 and the number of hundreds was 1, what is the answer to the formula?
amount = 197.18 - 1 * 100 -- 1 * 100 is done first, which your formula now becomes amount = 197.18 - 100 -- then amount would be
amount = 97.18
Next, determine the number of tens remaining in the check amount.
1. 97.18 \ 10 OR
2. int(97.18 / 10)
Answer #1 is 9
Answer #2 is 9.
9 means Ninety; use select to concatenate "Ninety" to the strAmount
then like previous example, subtract the number of tens from the check amount.
Finally, you will end up with only cents.
You will use the select/case to build the check amount as a string.
Does anyone have experience doing things like this? I would really appreciate any help you could give me because I'm completely lost. We're only supposed to use Select Case and If statements in completing the program.