c语言罗马数字转十进制,将罗马数字转换为十进制

嘿,我认为我很亲密,但我不太确定如何继续。所有与我的问题有关的问题都没有真正回答。那我得到现在的错误是将罗马数字转换为十进制

(33): error C2064: term does not evaluate to a function taking 1 arguments

(41): error C2064: term does not evaluate to a function taking 1 arguments

头文件:

using namespace std;

class romanType

{

public:

void printRoman(char romanNum);

int printDecimal(int& total);

int convertRoman(int& total);

void setRoman(char& roman);

romanType();

romanType(char);

private:

char romanNum[6];

int decimal;

int total;

};

实现:

#include "stdafx.h"

#include

#include

#include "romanType.h"

using namespace std;

romanType::romanType(char)

{

};

void romanType::printRoman(char romanNum)

{

cout << "Here is your number in Roman Numeral form: " << romanNum << endl;

};

int romanType::printDecimal(int& total)

{

cout << "Here is your number in Decimal form: " << total << endl;

return total;

};

void romanType::setRoman(char& romanNum)

{

};

int romanType::convertRoman(int& total)

{

int len = 0;

len = strlen(romanNum);

int count[1];

for(int i = 0; i < len; i++)

{

switch(romanNum[i])

{

case 'M':

count[i] = 1000;

break;

case 'm':

count[i] = 1000;

break;

case 'D':

count[i] = 500;

break;

case 'd':

count[i] = 500;

break;

case 'C':

count[i] = 100;

break;

case 'c':

count[i] = 100;

break;

case 'L':

count[i] = 50;

break;

case 'l':

count[i] = 50;

break;

case 'X':

count[i] = 10;

break;

case 'x':

count[i] = 10;

break;

case 'V':

count[i] = 5;

break;

case 'v':

count[i] = 5;

break;

case 'I':

count[i] = 1;

break;

case 'i':

count[i] = 1;

break;

default:

cout << "Error.." << endl;

}

total = total + count[0];

}

return total;

};

我的主:

#include "stdafx.h"

#include

#include

#include "romanType.h"

using namespace std;

int main()

{

romanType r;

char romanNum;

char choice;

int decimal;

int total;

cout << "Hello! Please enter your Roman Numeral: " << endl;

cin >> romanNum;

cout << endl;

r.setRoman(romanNum);

r.convertRoman(total);

cout << "Do you want the Roman Numeral or the Decimal?" << endl;

cout << "Press [D] for Decimal!" << endl << "Press [R] for Roman Numeral!" << endl;

cin >> choice;

if (choice == 'D' || choice == 'd')

r.printDecimal(total);

else if (choice == 'R' || choice == 'r')

r.printRoman(romanNum);

else

cout << "That wasn't the right button!" << endl;

system ("pause");

return 0;

}

我很确定我走在正确的轨道上。很高兴看到有关我的错误的任何提示或建议。

预先感谢

+1

哪些是第33和第41行? –

+0

顺便说一下,问题在于编写一个程序,将用罗马数字输入的数字转换为十进制。需要包含一个名为romanType的类和一个执行以下操作的对象: 将编号存储为罗马数字 将该编号转换并存储为十进制形式 按用户要求将该编号打印为罗马数字或十进制数 的罗马数字的十进制值是: M = 1000 d = 500 C = 100 L = 50 X = 10 V = 5 I = 1 –

+0

r.convertRoman(总);和r.printDecimal(total); –

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值