I'm having some trouble with a program that is suppose to convert integers to roman numerals. It's school work so i want to avoid asking for to much information but the thing that is causing the trouble is the outputs. It is suppose to display and error message if anything below 1 is entered or above 3,999 which it does, but it will also print the message that is suppose to be printed if the number entered fits in the boundries. I'm thinking i have done something wrong with the functions which i am not very familiar with but they need to be used if anyone any information that could help that would be great. PS: The cout statment in the ConvertToRoman function is just there as a placeholder/tester for me since i do not know how i am going to convert the int to roman numeral yet...anywhere here's what i have
Code:
#include <iostream>
#include <string>
using namespace std;
/****************Function Prototypes****************/
int GetTheNumber(int);
void ConvertToRoman(int, string);
void PrintResults(int, string);
/**************************************************/
int main()
{
int numbers = 0;
string roman;
char again;
GetTheNumber(numbers);
do
{
if (numbers < 1 || numbers > 3999)
cout << "Cannot convert that number: out of range" << endl;
else
{
ConvertToRoman(numbers, roman);
}
PrintResults(numbers, roman);
cout << "Would you like to enter another year? ";
cin >> again;
cout << endl;
}while(again == 'y');
return 0;
}
int GetTheNumber(int numbers)
{
cout << "Enter a number between 1 and 3,999: ";
cin >> numbers;
cout << endl;
return numbers;
}
void ConvertToRoman(int numbers,string roman)
{
if (numbers = 1000)
roman = "M";
else
cout << "wrong";
return;
}
void PrintResults(int numbers,string roman)
{
cout << "The roman equivilent of " << numbers << " is: " << roman << endl;
return;
}