I have to convert integers to Roman Numerals but I cannot have output
in the switch statment. I also cannot use print or println only
printf. I can't figure out hot to output without putting it in the
switch statment. Help?
|
|
0
|
|
|
|
Reply
|
dnlandes (1)
|
3/8/2007 4:07:28 AM |
|
A switch statement is shorthand for a series of if/then/else
statements.
dnlandes@gmail.com wrote:
>I have to convert integers to Roman Numerals but I cannot have output
>in the switch statment. I also cannot use print or println only
>printf. I can't figure out hot to output without putting it in the
>switch statment. Help?
--
Regards,
Casey
|
|
0
|
|
|
|
Reply
|
Casey
|
3/8/2007 5:01:44 AM
|
|
Please do not top post.
dnlandes@gmail.com wrote:
>> I have to convert integers to Roman Numerals but I cannot have output
>> in the switch statment. I also cannot use print or println only
>> printf. I can't figure out hot to output without putting it in the
>> switch statment. Help?
Casey Hawthorne wrote:
> A switch statement is shorthand for a series of if/then/else
> statements.
I read the OP's question as how to use a switch statement but not have output
occur within it.
If that interpretation is correct:
If you cannot put the output inside the switch, where else can you put it?
What information needs to be available at that point in order to produce the
desired output?
-- Lew
|
|
0
|
|
|
|
Reply
|
Lew
|
3/8/2007 6:22:26 AM
|
|
dnlandes@gmail.com wrote:
> I have to convert integers to Roman Numerals but I cannot have output
> in the switch statment. I also cannot use print or println only
> printf. I can't figure out hot to output without putting it in the
> switch statment. Help?
>
Step 1.
Generate Roman Numeral representation (*) of the int value
with a switch inside a loop.
Step 2.
Display Roman Numeral representation.
(*) hint; result should probably be a String, and you probably want to
use StringBuffer while building it.
|
|
0
|
|
|
|
Reply
|
Thomas
|
3/8/2007 7:48:51 AM
|
|
Thomas Schodt wrote:
> dnlandes@gmail.com wrote:
>
>> I have to convert integers to Roman Numerals but I cannot have output
>> in the switch statment. I also cannot use print or println only
>> printf. I can't figure out hot to output without putting it in the
>> switch statment. Help?
>>
>
> Step 1.
> Generate Roman Numeral representation (*) of the int value
> with a switch inside a loop.
> Step 2.
> Display Roman Numeral representation.
>
> (*) hint; result should probably be a String, and you probably want to
> use StringBuffer while building it.
Start by designing an algorith to do the conversion.
Then take it step by step... do a manual walk through on the algorithm
and see if you can write the code for it.
As for your issue with the Switch statement, you really don't need one.
If you have an array you can use some sort of index to pull out what you
want to display.
|
|
0
|
|
|
|
Reply
|
John
|
3/8/2007 9:02:50 PM
|
|