Is there a wap version of your site?
Thanks for all the help with the roman number thing
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What can I do?
• What to Read?
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Сообщества
• Talxy Chat
• Horoscope
• Online
 
Зарегистрируйся!

QAIX > C/C++ Programming > Thanks for all the help with the roman number thing 30 October 2005 16:02:49

  Recent blog posts: 
  They have birthday today: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Moderators:

Thanks for all the help with the roman number thing

Raphael 30 October 2005 16:02:49
 again thanks , this is what we ended up doin in class.
eded up useing case, and class

#include<iostream>
#include<string>
#include "roman.h"
using namespace std;

void romanType::setroman­(string array)
{
roman=array;
}

void romanType::setnumbe­r(int mynumber)
{
number=mynumber;
}
void romanType::printrom­an()
{
cout <<"The roman number is "<< roman<<endl;
}
void romanType::printnum­ber()
{
cout <<"the number is "<< number<<endl;
}
void romanType::convertr­oman()//char array[]);
{

int p = 1000;
int sum = 0;

for(int a=0; a < roman.length();a++)­
{
switch (roman[a])
{
case 'M': sum+=1000;
if(p<1000)
sum-=(p*2);
p=1000;
break;
case 'D': sum+=500;
if(p<500)
sum-=(p*2);
p=500;
break;
case 'C': sum+=100;
if(p<100)
sum-=(p*2);
p=100;
break;
case 'L': sum+=50;
if(p<50)
sum-=(p*2);
p=50;
break;
case 'X': sum+=10;
if(p<10)
sum-=(p*2);
p=10;
break;
case 'V': sum+=5;
if(p<5)
sum-=(p*2);
p=5;
break;
case 'I': sum+=1;
if(p<1)
sum-=(p*2);
p=1;
break;
default: cout <<"Invalid selection."<<endl;

}

}
number=sum;
}

romanType::romanTyp­e()
{
roman="I";
number=0;

}

romanType::romanTyp­e(string array)
{
roman=array;
number=0;
}

romanType::romanTyp­e(int num)
{
roman="I";
number=num;
}
//=================­====================­====================­===========
#ifndef ROMANTYPE
#define ROMANTYPE

#include<string>
using namespace std;
class romanType
{
private:
string roman;
int number;
public:
void setroman(string array);
void setnumber(int);
void convertnumb(int);
void convertroman();//ch­ar array);
void printroman();
void printnumber();

romanType();
romanType(string array);
romanType(int);

};
#endif






-------------------­----- Yahoo! Groups Sponsor -------------------­-~-->
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yah­oo.com/A77XvD/vlQLAA­/TtwFAA/EbFolB/TM
-------------------­--------------------­--------------------­---------~->

Add comment
Victor A. Wagner Jr. 30 October 2005 08:35:35 permanent link ]
 At 07:17 2005-10-29, you wrote:>again thanks , this is what we ended up doin in class.>eded up useing case, and class

other than it doesn't always give the right answer, and the style
sucks, it's fine.

#include<iostream>­>#include<string>>#i­nclude "roman.h">using namespace std;>
void romanType::setroman­(string array)>{> roman=array;>}>
void romanType::setnumbe­r(int mynumber)>{> number=mynumber;>}>­void romanType::printrom­an()>{> cout <<"The roman number is "<< roman<<endl;>}>void­ romanType::printnum­ber()>{> cout <<"the number is "<< number<<endl;>}>voi­d romanType::convertr­oman()//char array[]);>{>
int p = 1000;> int sum = 0;>
for(int a=0; a < roman.length();a++)­> {> switch (roman[a])> {> case 'M': sum+=1000;> if(p<1000)> sum-=(p*2);> p=1000;> break;> case 'D': sum+=500;> if(p<500)> sum-=(p*2);> p=500;> break;> case 'C': sum+=100;> if(p<100)> sum-=(p*2);> p=100;> break;> case 'L': sum+=50;> if(p<50)> sum-=(p*2);> p=50;> break;> case 'X': sum+=10;> if(p<10)> sum-=(p*2);> p=10;> break;> case 'V': sum+=5;> if(p<5)> sum-=(p*2);> p=5;> break;> case 'I': sum+=1;> if(p<1)> sum-=(p*2);> p=1;> break;> default: cout <<"Invalid selection."<<endl;>­
}>
}>number=sum;>}>
romanType::romanTy­pe()>{> roman="I";> number=0;>
}>
romanType::romanTy­pe(string array)>{> roman=array;> number=0;>}>
romanType::romanTy­pe(int num)>{> roman="I";> number=num;>}>//===­====================­====================­====================­=====>#ifndef ROMANTYPE>#define ROMANTYPE>
#include<string>>u­sing namespace std;>class romanType>{>private­:> string roman;> int number;> public:> void setroman(string array);> void setnumber(int);> void convertnumb(int);> void convertroman();//ch­ar array);> void printroman();> void printnumber();>
romanType();> romanType(string array);> romanType(int);>
};>#endif>
To unsubscribe, send a blank message to ><mailto:c-prog-uns­ubscribe-hHKSG33Tihh­bjbujkaE4pw@public.g­mane.org>.>Yahoo! Groups Links>

Victor A. Wagner Jr. http://rudbek.com
The five most dangerous words in the English language:
"There oughta be a law"



-------------------­----- Yahoo! Groups Sponsor -------------------­-~-->
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yah­oo.com/A77XvD/vlQLAA­/TtwFAA/EbFolB/TM
-------------------­--------------------­--------------------­---------~->

Add comment
Dm_451 30 October 2005 16:02:49 permanent link ]
 --- In c-prog-hHKSG33Tihhb­jbujkaE4pw@public.gm­ane.org, "Raphael" <icomigo@h...> wrote:>
again thanks , this is what we ended up doin in class.> eded up useing case, and class

I truly hope you are not satisfied with this program, Raphael. If you
read Ray's post on this, I believe you'll find the info you need to
make a good program.

Don't settle for programs like this. You can do much better.

Dave







-------------------­----- Yahoo! Groups Sponsor -------------------­-~-->
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yah­oo.com/A77XvD/vlQLAA­/TtwFAA/EbFolB/TM
-------------------­--------------------­--------------------­---------~->

Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или УК РФ.


QAIX > C/C++ Programming > Thanks for all the help with the roman number thing 30 October 2005 16:02:49

see also:
Copy function usage ?
array issues
installing mysql on win98
пройди тесты:
see also:
Privas!
The Best Video Converter-a versatile…

  Copyright © 2001—2008 QAIX
Idea: Miсhael Monashev
Помощь и задать вопросы можно в сообществе support.qaix.com.
Сообщения об ошибках оставляем в сообществе bugs.qaix.com.
Предложения и комментарии пишем в сообществе suggest.qaix.com.
Информация для родителей.
Write us at:
If you would like to report an abuse of our service, such as a spam message, please .