Advertisement
SmellyBadger

Untitled

Nov 5th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <string>
  4. using namespace std;
  5.  
  6.  
  7.  
  8. bool IsvalidNumForBase(int, int);
  9. int baseToDecimal(int, int);
  10. float someDecimals(float, float);
  11. void decimalToBase(int, int, int &, int &);
  12. int decimalOperation(int decinum1, int decinum2, char o);
  13.  
  14. // Variables
  15. int base = 0; // the base number the user will enter
  16. int num1, num2; // integers that must be less than the base
  17. int decinum1, decinum2, opResult; // the decimal value for nums 1 and 2
  18. bool IsvalidNum = true;
  19. char op;
  20. int resultWithNoTrailingZero, numTrailingZeros;
  21. int main()
  22. {
  23.  
  24. cout << "Enter the base: " << endl;
  25. cin >> base;
  26.  
  27. IsvalidNum = IsvalidNumForBase(num1, num2);
  28. if (IsvalidNumForBase == false)
  29. {
  30. return false;
  31. }
  32.  
  33. else
  34. {
  35. cout << "Enter the first number: " << endl;
  36. cout << "Enter the second number: " << endl;
  37. cout << endl;
  38.  
  39. decinum1 = baseToDecimal(base, num1);
  40. baseToDecimal(base, num1);
  41. cout << "Decimal value for first Number: " << decinum1 << endl;
  42.  
  43. decinum2 = baseToDecimal(base, num2);
  44. baseToDecimal(base, num2);
  45. cout << "Decimal value for the second number" << decinum2 << endl;
  46.  
  47. opResult = decimalOperation(decinum1, decinum2, op);
  48. decimalOperation(decinum1, decinum2, op)
  49.  
  50.  
  51. decimalToBase(opResult, base, resultWithNoTrailingZero, numTrailingZeros)
  52. {
  53. int remainder = 0;
  54. while (opResult > 0)
  55. {
  56. remainder = opResult % base;
  57. resultWithNoTrailingZero += resultWithNoTrailingZero * 10 + remainder;
  58. if (resultWithNoTrailingZero == 0)
  59. numTrailingZeros++;
  60. opResult = opResult / base;
  61. }
  62. return;
  63. }
  64. }
  65. }
  66. //params: (in, in)
  67. int baseToDecimal(base, )
  68. {
  69. int dec = 0;
  70. int digit = 0; // will hold each digit of the number
  71. int counter = 0;
  72. while (dec > 0)
  73.  
  74. return
  75. }
  76. //params: (in, in, in/out, in/out)
  77. void decimalToBase(int opResult,int base,int resultWithNoTrailingZero,int numTrailingZeros)
  78. {
  79. int remainder = 0;
  80. while (opResult > 0)
  81. {
  82. remainder = opResult % base;
  83. resultWithNoTrailingZero += resultWithNoTrailingZero * 10 + remainder;
  84. if (resultWithNoTrailingZero == 0)
  85. numTrailingZeros++;
  86. opResult = opResult / base;
  87. }
  88. }
  89.  
  90. //params: (in, in, in)
  91. int decimalOperation(int decinum1, int decinum2, char 'o')
  92. {
  93. if (op == '+')
  94. {
  95. opResult = decinum1 + decinum2;
  96. }
  97. else if (op == '-')
  98. {
  99. opResult = decinum1 - decinum2;
  100. }
  101. else if (op == '*')
  102. {
  103. opResult = decinum1 * decinum2;
  104. }
  105. else
  106. {
  107. opResult = decinum1 / decinum2;
  108. }
  109. return;
  110. }
  111. // params: (in, in)
  112. bool IsvalidNumForBase(int num1, int num2)
  113. {
  114.  
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement