Guest User

Untitled

a guest
Nov 23rd, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <conio.h>
  5.  
  6. using namespace std;
  7.  
  8. //Function used to represent interger a as a Roman Numeral string
  9. /*string romanNumeral (int a)
  10. {
  11. //numeral is intiliazed as a string object to store the result to be returned.
  12. string numeral;
  13. // Checks to see if the integer is positive
  14. if (a > 0)
  15. {
  16. //Loop is used to add M to the end of the string and subtract 1000 from the passed in integer
  17. while (a >= 1000)
  18. {
  19. numeral.append("M");
  20. a = a - 1000;
  21. }
  22. //Loop is used to add CM to the end of the string and subtract 900 from the passed in integer
  23. while (a >= 900)
  24. {
  25. numeral.append("CM");
  26. a = a-900;
  27. }
  28. //Loop is used to add d to the end of the string and subtract 500 from the passed in integer
  29. while (a >= 500)
  30. {
  31. numeral.append("D");
  32. a = a- 500;
  33. }
  34. //Loop is used to add CD to the end of the string and subtract 400 from the passed in integer
  35. while (a >= 400)
  36. {
  37. numeral.append("CD");
  38. a = a-400;
  39. }
  40. //Loop is used to add C to the end of the string and subtract 100 from the passed in integer
  41. while (a >= 100)
  42. {
  43. numeral.append("C")
  44. a = a - 100;
  45. }
  46. //Loop is used to add XC to the end of the string and subtract 90 from the passed in integer
  47. while (a >= 90)
  48. {
  49. numeral.append("XC");
  50. a = a - 90;
  51. }
  52. //Loop is used to add L to the end of the string and subtract 50 from the passed in integer
  53. while (a >= 50)
  54. {
  55. numeral.append("L");
  56. a = a - 50;
  57. }
  58. //Loop is used to add XL to the end of the string and subtract 40 from the passed in integer
  59. while (a >= 40)
  60. {
  61. numeral.append("XL");
  62. a = a - 40;
  63. }
  64. //Loop is used to add X to the end of the string and subtract 10 from the passed in integer
  65. while (a >= 10)
  66. {
  67. numeral.append("X");
  68. a = a - 10;
  69. }
  70. //Loop is used to add IX to the end of the string and subtract 9 from the passed in integer
  71. while (a >= 9)
  72. {
  73. numeral.append("IX");
  74. a = a - 9;
  75. }
  76. //Loop is used to add V to the end of the string and subtract 5 from the passed in integer
  77. while (a >= 5)
  78. {
  79. numeral.append("V");
  80. a = a - 5;
  81. }
  82. //Loop is used to add IV to the end of the string and subtract 4 from the passed in integer
  83. while (a >= 4)
  84. {
  85. numeral.append("IV");
  86. a = a - 4;
  87. }
  88. //Loop is used to add I to the end of the string and subtract 1 from the passed in integer
  89. while (a >= 1)
  90. {
  91. numeral.append("I");
  92. a = a - 1;
  93. }
  94. }
  95. else
  96. {
  97. return "Invalid entry";
  98. }
  99. return numeral;
  100. }
  101. */
  102. int main()
  103. {
  104. //Creates an integer to store the number from the file
  105. int toad = 0;
  106. // Creates a stream to open integer file
  107. ifstream mario("integers.txt");
  108. // Checks to see if file exists
  109. if (!mario)
  110. {
  111. cerr << "File does not exist\n";
  112. return(1);
  113. }
  114. //Iterates through the stream while it still returns anything but null
  115. while (mario >> toad)
  116. {
  117. cout << toad << ":\t" << romanNumeral(toad);
  118. }
  119. }
  120.  
  121.  
  122. 1>------ Build started: Project: hw01_9__11, Configuration: Debug Win32 ------
  123. 1>LINK : error LNK2001: unresolved external symbol _main
  124. 1>C:\Users\Thomas\documents\visual studio 2010\Projects\hw01_9__11\Debug\hw01_9__11.exe : fatal error LNK1120: 1 unresolved externals
  125. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Add Comment
Please, Sign In to add comment