- #1
bbeth
- 2
- 0
I am trying to make a program that let's a user input a number(which counts up 20 elements) and that is converted into roman numerals. I need 2 parallel arrays, one which holds only positive numbers and one which holds only strings. I keep getting 2 error messages "+= int differs in levels of undirection from 'const char[2]'" and "+= illegal right operand has type 'const char[3]'". Any help would be very much appreciated.
This is what I have so far.
#include "stdafx.h"
#include <string>
#include <iomanip>
#include <iostream>
#include <cmath>
using namespace std;
void getRoman(int& roman);
const char;
enum romanType{ M = 1000,D = 500,C = 100,L = 50,X = 10,V = 5, I = 1};
int _tmain( )
{
int n;
int numeral;
int Decimal;
int roman;
string list[20];
cout << "Enter an integer from 1-5000" << endl;
cin >> n;
if((Decimal >= 5000) || (Decimal <=0))
{
cout << "Invalid Integer" << endl;
}
for (int row = 0; row < 20; row++)
{
list[row]=Decimal;
list[row]=n;
}
for( int n = 1; n <= 9999; n++)
{
cout << list[n] << " "<< Decimal;
}
for(n = 1; n <= 5000; n++)
if( n < 5000 )
{
roman = (n / 1000);
roman += "M";
}
roman%= 1000;
if( n >= 100)
{
roman =(Decimal / 100);
if( roman ==9)
{
roman += "CM";
}
else if (roman >= 5)
{
roman += "D";
for( int i = 0; i < roman-5; i++)
{
roman += "C";
}
}
else if ( roman == 4)
{
roman += "CD";
}
else if (roman >1)
{
for( int i= 0; i < roman; i++)
{
roman += "C";
}
}
Decimal %= 100;
}
if ( Decimal >= 10)
{
roman = (Decimal / 10);
if ( roman ==9)
{
roman += "XC";
}
else if( roman >= 5)
{
roman += "L";
for( int n = 0; n < roman-5; n++)
{
roman += "X";
}
}
else if ( roman == 4)
{
roman += "XL";
}
else if ( roman >= 1)
{
for( int n = 0; n < roman; n++)
{
roman += "X";
}
}
Decimal %= 10;
}
if( Decimal >= 1)
{
roman = Decimal;
if( roman == 9)
{
roman += "IX";
}
else if( roman >=5)
{
roman += "V";
for( int n = 0; n < roman-5;n++)
{
roman += "I";
}
}
else if( roman ==4)
{
roman += "IV";
}
else if( roman >= 1)
{
for( int n = 0; n < roman; n++)
{
roman += "I";
}
}
}
system ("pause");
return 0;
}
This is what I have so far.
#include "stdafx.h"
#include <string>
#include <iomanip>
#include <iostream>
#include <cmath>
using namespace std;
void getRoman(int& roman);
const char;
enum romanType{ M = 1000,D = 500,C = 100,L = 50,X = 10,V = 5, I = 1};
int _tmain( )
{
int n;
int numeral;
int Decimal;
int roman;
string list[20];
cout << "Enter an integer from 1-5000" << endl;
cin >> n;
if((Decimal >= 5000) || (Decimal <=0))
{
cout << "Invalid Integer" << endl;
}
for (int row = 0; row < 20; row++)
{
list[row]=Decimal;
list[row]=n;
}
for( int n = 1; n <= 9999; n++)
{
cout << list[n] << " "<< Decimal;
}
for(n = 1; n <= 5000; n++)
if( n < 5000 )
{
roman = (n / 1000);
roman += "M";
}
roman%= 1000;
if( n >= 100)
{
roman =(Decimal / 100);
if( roman ==9)
{
roman += "CM";
}
else if (roman >= 5)
{
roman += "D";
for( int i = 0; i < roman-5; i++)
{
roman += "C";
}
}
else if ( roman == 4)
{
roman += "CD";
}
else if (roman >1)
{
for( int i= 0; i < roman; i++)
{
roman += "C";
}
}
Decimal %= 100;
}
if ( Decimal >= 10)
{
roman = (Decimal / 10);
if ( roman ==9)
{
roman += "XC";
}
else if( roman >= 5)
{
roman += "L";
for( int n = 0; n < roman-5; n++)
{
roman += "X";
}
}
else if ( roman == 4)
{
roman += "XL";
}
else if ( roman >= 1)
{
for( int n = 0; n < roman; n++)
{
roman += "X";
}
}
Decimal %= 10;
}
if( Decimal >= 1)
{
roman = Decimal;
if( roman == 9)
{
roman += "IX";
}
else if( roman >=5)
{
roman += "V";
for( int n = 0; n < roman-5;n++)
{
roman += "I";
}
}
else if( roman ==4)
{
roman += "IV";
}
else if( roman >= 1)
{
for( int n = 0; n < roman; n++)
{
roman += "I";
}
}
}
system ("pause");
return 0;
}