Arabic Numerals to Roman Numerals

In this question, we will utilize a web service that converts Arabic numerals to Roman numerals. Below is a skeleton for using this web service (gsoapNumRoman.rar at VLT) to convert one Arabic number to Roman number. You need to modify the main( ) by introducing a one-dimension integer array: x[5] and assigning the following values to the array elements:

x[0] = 1980 x[1] = 1992 x[2]=2000 x[3] = 2010 x[4]=2013

The original main( ) is:

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
int main( )
{
  struct soap *soap = soap_new();  //new soap instance
  int num;
  string myResult;
  
  int getnum;
  cout<<"Number (positive, less than 100000): ";
  cin>>getnum;
  num = getnum;
  
  if(num>=100000){num=-1;} //limit size of num

  if (soap_call_ns1__IntToRoman(soap, NULL, NULL, num, myResult) == 0)
  {  //soap method for getting roman number, determined from numRoman.h
	if(myResult.compare("")!=0){//if the number is valid
		cout<<"\n Number "<<num<<" is "<<myResult<<"  \n\n";
	}else
	{
		cout<<"\n Number is invalid...\n\n";
	}
  }
  else
  {
    soap_print_fault(soap, stderr);
  }
  soap_destroy(soap); //destroy soap instance
  system("pause");
  return 0;
}


Hint: You should use a for loop to conduct the conversion for all the array elements and use cout to print out the result on computer screen.


I did introduce the array, but I didn't know how to set the for loop:

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
#include "soapH.h"    // include the generated proxy
#include <string>
#include <iostream>
#include <stdlib.h>
#include "IRomanbinding.nsmap" //include namespace map
using namespace std;

int main( )
{
  struct soap *soap = soap_new();  //new soap instance
  int num;
  string myResult;
  
  int getnum;
  cout<<"Number (positive, less than 100000): ";
  cin>>getnum;
  num = getnum;

  int x[5]= { 1980, 1992, 2000, 2010, 2013 };

  
  if(num>=100000){num=-1;} //limit size of num

  if (soap_call_ns1__IntToRoman(soap, NULL, NULL, num, myResult) == 0)
  {  //soap method for getting roman number, determined from numRoman.h
	if(myResult.compare("")!=0){//if the number is valid
		cout<<"\n Number "<<num<<" is "<<myResult<<"  \n\n";
	}else
	{
		cout<<"\n Number is invalid...\n\n";
	}
  }
  else
  {
    soap_print_fault(soap, stderr);
  }
  soap_destroy(soap); //destroy soap instance
  system("pause");
  return 0;
}


Help please?

thanks!
Topic archived. No new replies allowed.