![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Programming A discussion forum for programs and programming used in tech-related businesses. |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Moderator: Design
Join Date: Oct 2006
Location: Richmond, B.C.; Canada
Posts: 1,452
OS: Windows XP [Version 5.1.2600] SP3 | Ubuntu Jaunty Jackalope | Windows 7 BETA
|
C++ switch, no idea.
This is a school project.
Code:
//File Name: numeral_conversion.cpp
//Purpose: To convert roman numerals into arabic digits.
//Notes: Possible re-tooling for other numbering systems.
//completely impossible!!!
#include <iostream>
#include <conio.h>
void main()
{
//allocation of storage for variables
int arabic_base;
cin >> code(numeral)
{
case 'I' : arabic_base = 1;
break;
case 'V' : arabic_base = 5;
break;
case 'X' : arabic_base = 10;
break;
case 'L' : arabic_base = 50;
break;
case 'C' : arabic_base = 100;
break;
case 'D' : arabic_base = 500;
break;
case 'M' : arabic_base = 1000;
break;
}
// I have no idea how this is supposed to work. Someone help me.
Someone please help before I completely lose my mind and throw my manriki at the monitor (again)! I already crashed my machine over a stupid infinite loop error, so I am being careful this time.
__________________
![]() Validate your Markup Validate your CSS Notepad++ Please use [html], [php], and [code] when posting code or markup. I do not help by Private Message or e-mail. If for some reason I have over-looked a reply to a thread that I have previously replied to, then send me a message. |
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#2 (permalink) |
|
Registered User
Join Date: Oct 2008
Posts: 6
OS: none
|
Re: C++ switch, no idea.
hello dm01,
I don't really know or understand "arabic digits" but here is how you declare a switch statement: Code:
switch(this){
case 1 : doThis();
break;
case 2 : doThis2();
break;
default : doThat();
}
Code:
if(this == 1)
{
doThis();
}
esle if(this == 2)
{
doThis2();
}
else {
doThat();
}
So what im guessing (and i don't mean to do your homework for you) what you need is something like this: Code:
#include <iostream>
using namespace std;
int main(){
int arabic;
char* roman;
cin >> arabic;
switch(arabic){
case 1 : roman = "I";
break;
case 2 : roman = "II";
break;
case 3 : roman = "III";
break;
case 4 : roman = "IV";
break;
// and so on...
}
cout << "roman: " << roman;
return 0;
}
|
|
|
|
|
|
#3 (permalink) |
|
Moderator: Design
Join Date: Oct 2006
Location: Richmond, B.C.; Canada
Posts: 1,452
OS: Windows XP [Version 5.1.2600] SP3 | Ubuntu Jaunty Jackalope | Windows 7 BETA
|
Re: C++ switch, no idea.
That's almost exactly what I need, I think. There are a couple of stupid loops I need to figure out (extra credit) but I can handle that (I hope).
I'll try what you suggested and see how it goes.
__________________
![]() Validate your Markup Validate your CSS Notepad++ Please use [html], [php], and [code] when posting code or markup. I do not help by Private Message or e-mail. If for some reason I have over-looked a reply to a thread that I have previously replied to, then send me a message. |
|
|
|
![]() |
| Thread Tools | |
|
|