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:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* 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
Go Back   Tech Support Forum > The IT Pro > Programming
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read


Programming A discussion forum for programs and programming used in tech-related businesses.

Reply
 
LinkBack Thread Tools
Old 10-05-2008, 12:44 AM   #1 (permalink)
Moderator: Design
 
dm01's Avatar
 
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

My System

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.
The idea of the program is to write out numbers written in Arabic numerals into Roman numerals. I think I need C++ to recognize place value (that part was not explained in class very well) and I think a switch can be configured to do so. The problem is I don't know how these switch things work. The example above was pretty much copied out of the textbook. I thought I'd ask here before going for extra help with the lady with the weird accent no one can understand and has not been definitively placed as to origin.

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.
dm01 is online now  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
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

Old 10-07-2008, 07:21 PM   #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();
}
is common to use switch statements to replace if-else statements, and what is meant by the code above is similar to this:

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;
}
cunaguaro is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 10-07-2008, 07:46 PM   #3 (permalink)
Moderator: Design
 
dm01's Avatar
 
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

My System

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.
dm01 is online now  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -7. The time now is 09:31 PM.



Copyright 2001 - 2009, Tech Support Forum
Home Tips Plus | Outdoor Basecamp | Automotive Support Forum

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85